0

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

  • 1
    Simply do not put these into `createUrl()`. With this however, you have a problem getting category and group ID. It's very common just to append IDs to the string `hbbh/object/category/digital_suplies-2/mobile-20`. – chris--- Jul 28 '14 at 11:28
  • @chris thanks, if I keep on with your solution, do I have SEO? –  Jul 28 '14 at 13:47
  • I'm no seo expert so I cannot tell you if this would be good sorry. But with Yii it is very easy to change your urls. Just do a little research on seo. – chris--- Jul 28 '14 at 19:06
  • I search for it over and over but didn't find complete refrence. So if you know anywhere please guide me. Thank again –  Jul 29 '14 at 00:14
  • There is no wrong or right here, this is better than that. It just depends. I cannot give you any more advice. Look how other big sites manage this url thing, they are probably doing it right, because they have researched a lot. So it can't be that bad to do it the same. – chris--- Jul 29 '14 at 13:05

1 Answers1

0

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>',