Hi everyone,
I’m new to this forum, and i have been studying yii for one week. Today i’m facing my first problem:
I’m trying to make URLs more SEO friendly, by writing some rules for urlManager; in particular, I created a CRUD using Gii, and wrote this rule in order to customize the URL of viewing action:
...
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=> false,
'urlSuffix'=>'.html',
'caseSensitive' => false,
'rules'=>array(
'site/pages/<view:\w+>'=>'site/page',
'products/<category:\w+>'=>'products/index',
'<id:\d+>-<product:\w+>'=>'products/view',
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
...
The URL for the ‘view’ action is generated by this code:
CHtml::link($html, array('view', 'id' => $data->id, 'product' => str_replace(' ', '-', $data->product)), array('class'=>'link'));
The thing is that the URL example/1-product-name.html generates this output, and i’m stuck…
Error 404
Unable to resolve the request "1-product-name".
Any help would be very appreciate.
Thank you very much.
Best regards
PS:i’m a non native english speaker…forgive me for my errors!