Hey,
I’ve been searching all around Stackoverflow and YII forums, there are many answers, which didn’t help me…
This is my case,
I have controller called: proj and an action called view.
The desired name gets sometimes with special chars such as: [+,!#$%^&*-]
So when I’m running createUrl() function it returns me not so friendly url.
For example:
qa-mysite/proj/1029/Conservation+of+the+Vermont+Salt+Pan+System%2C+Hermanus%2C+South+Africa.
id = 1029
name = Conservation of the Vermont SaltPan System, Hermanus, South Africa.
I want the result to be:
qa-mysite/proj/1029/conservation-of-the-vermont-salt-pan-system-hermanus-south-Africa
So actually i need to strip the special chars and change the delimiter between spaces to "-" instead of "+".
My current configurations of the curlManager are:
‘urlManager’=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'appendParams' => true,
'rules'=>array(
//array('proj/view/<name:\w+>', 'pattern'=>'proj/<id:\d+>'),
//'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'proj/<id:\d+>/<name:\w+>'=>array('proj/view', 'caseSensitive'=>false),
'<controller>/<id:\d+>/<name:.*?>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
)
CreateUrl example:
$this->createUrl(‘proj/view’, array(‘id’ => $data->id, ‘name’ => $data->name));
After the urls will be changed I need to do 301 redirects of the old ones to the new-seo-friendly urls.
Note: I cannot do hardcoded str_replace.
Many thanks for any help :]