I’m trying to rewrite an url created via createUrl method:
Yii::app()->createUrl('user/user/view',array('id'=>$id));
In urlManager, I set a rule that almost like the instruction:
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName' =>false,
'rules'=>array(
// core
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
//this url
'user/<id:\w+>'=>array('user/user/view', 'urlSuffix'=>'.html'),
),
),
It worked without any problem.
Now I want to remove the .html extension with the rule below instead:
'user/<id:\w+>'=>'user/user/view',
And it returns error
. It seems that the regex pattern
<id:\w+>
used to rewrite url, is no longer correct. How could I fix it?