You forgot the params/id part. Use the appropriate rule below:
'experience/color/<param:\w+>'=>'experience/listByColor/'
'experience/color/<id:\d+>'=>'experience/listByColor/'
'experience/color/<color>'=>'experience/listByColor/'
문제
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'gii'=>'gii',
'gii/<controller:\w+>'=>'gii/<controller>',
'gii/<controller:\w+>/<action:\w+>'=>'gii/<controller>/<action>',
'<controller:\w+>/<action:\w+>/<param:\w+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'<controller:\w+>'=>'<controller>/index',
),
'showScriptName'=>false,
Those are the rules I have applied.
If I do:
http://something.dev/experience/listByColor/Red
I get all experiences with color Red.
actionListByColor($color);
This works.
I wish the same to work when the user does:
http://something.dev/experience/color/Red
I've tried those rules:
'experience/color/'=>'experience/listByColor/'
But I always get:
System couldn't found the requested action "color".
How can I make this work?
It seems that urlFormat is NOT fit for this, because it seems to expect a valid path on the left side of =>
and, on this case, we haven't any valid path there.
No other way?
해결책
You forgot the params/id part. Use the appropriate rule below:
'experience/color/<param:\w+>'=>'experience/listByColor/'
'experience/color/<id:\d+>'=>'experience/listByColor/'
'experience/color/<color>'=>'experience/listByColor/'