Hi,
I have rules like those:
‘<action:\w+>’ => ‘<controller>/<action>’,
‘<controller:\w+>/<id:\d+>’=>’<controller>/view’,
‘<controller:\w+>/<action:\w+>/<id:\d+>’=>’<controller>/<action>’,
‘<controller:\w+>/<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+>' => '/',
'<controller:\w+>/<id:\d+>'=>'/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'/',
'<controller:\w+>/<action:\w+>'=>'/',
or an url only without the controller name:
'<action:[\w\-]+>' => 'shop/<action>'
or
''=>'map/index', // homepage is site index
Read the api examples in the beginning from CUrlManager http://www.yiiframework.com/doc/api/1.1/CUrlManager/
or delete these two lines and look what happens
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'/',
'<controller:\w+>/<action:\w+>'=>'/',
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…