Reputation: 83
What would be the correct rule in the urlManager
in order for it to accept string ids? It shows Error 404 on actionView. Url: /sampleSite/index.php/transaction/I201303001.
This is how my urlManager
looks like:
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>true,
'rules'=>array(
'<controller:\w+>/<id:\d+>' =>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' =>'<controller>/<action>',
'<controller:\w+>/<action:\w+>/<id:>' =>'<controller>/<action>',
'<controller:\w+>/<action:\w+>' =>'<controller>/<action>',
),
),
Thanks in advance!
Upvotes: 0
Views: 1961
Reputation: 611
Try using regExp to accept any string (including numbers)
'rules'=>array(
'<controller:\w+>/<id:[a-zA-Z0-9-]+>' =>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' =>'<controller>/<action>',
'<controller:\w+>/<action:\w+>/<id:>' =>'<controller>/<action>',
'<controller:\w+>/<action:\w+>' =>'<controller>/<action>',
),
Upvotes: 1
Reputation: 4114
'rules'=>array(
'<module:\w+>/<controller:\w+>/<id:\w+>' =>'<module>/<controller>/view',
'<module:\w+>/<controller:\w+>/<action:\w+>/<id:\w+>' =>'<module>/<controller>/<action>',
'<module:\w+>/<controller:\w+>/<action:\w+>' =>'<module>/<controller>/<action>',
'<controller:\w+>/<id:\w+>' =>'<module:\w+>/<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\w+>' =>'<controller>/<action>',
'<controller:\w+>/<action:\w+>' =>'<controller>/<action>',
),
Upvotes: 0