phpurlyiiuser-friendly

Beautify Yii URLs


I have URL like below:

hbbh/object/category/id/4/name/category_name/gId/3/group/group_name

And I want to change it to something like below:

hbbh/object/category/category_name/group_name

Also I added below rule to urlManager rules:

'<_c:(object|auction)>/<_a:(category)>/<name:\w+>/<group:\w+>' => '<_c>/<_a>',

The URL generated after these codes is:

hbbh/object/category/digital_suplies/mobile?id=2&gId=20

Now is there anyway to remove ?id=2&gId=20 at the end of URL? Any suggestion will be apreciated Thanks in advance


Solution

  • Unfortunately there isn't such appropriate capability. The best way is format it, to be sound good.
    for example we can change it to this format:

    hbbh/object/category/digital_suplies-2/mobile-20  
    

    By changing urlManager as below:

    '<_c:(object|auction)>/<_a:(category)>/<name:\w+>-<cid:\d+>/
                           <group:\w+>-<gid:\d+>' => '<_c>/<_a>',