How To Remove Controler/actrion Name From Url


I have rules like those:

‘<action:\w+>’ => ‘<controller>/<action>’,




and urls like: /site/index/shop/3/category/4 are working, but I need something like this /shop/3/category/4 (without controller/action name).

‘/’=>’/site/index’ - this rules is not removing this controler/action name, why and that can I do now?

Have you tried to remove the controller and action from your rules?

Like this:

'<action:\w+>' => '/',




or an url only without the controller name:

'<action:[\w\-]+>' => 'shop/<action>'


''=>'map/index', // homepage is site index

Read the api examples in the beginning from CUrlManager

or delete these two lines and look what happens



Hi Sarah, unfortunately it’s not working for me ;( This is working ‘/shop/<shop:\d+>’=>’/site/index’, but I can’t use this because I have multiple optional parameters and if I would like to use this then I would have to to prepare dozen of rules…