URL Management dynamic parameters

I am trying to work out a URL rule to apply to convert the following url

http://localhost/page/viewjob/id/85345/Php-Developer-Required

where ‘page’ is the controller and ‘viewjob’ is the action and ‘id’ is the parameter

I need to convert it to an seo friendly url which is below

http://localhost/jobs/85345-Php-Developer-Required

The current setup I have in the config file is as follows.




		'urlManager'=>array(

			'urlFormat'=>'path',

            'showScriptName' => false,

			'rules'=>array(

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

                '/jobs/\w+' => '<page>/<viewjob>/id-\w+',                


			),

		),



I have tried to reading the manual several times but don’t really understand the rules that well and how

to apply it in this case.

The rules above map the matches controller on the left and put it into the routing on the right. In your case you’ll want a rule something like:




'/jobs/<id:\d+>-.*' => 'page/viewjob'



Not tested.

I had to modify the code slightly but I think I am getting a bit more idea on

URL Management than I had before…

This:


'jobs/<id:\d+>/*' => 'page/viewjob/id/<id>/',

Creates: http://localhost/jobs/85345/Php-Developer-Required

I have tried modifiying it further


'jobs/<id:\d+>-.*' => 'page/viewjob/id/<id>/',

But this doesn’t work

I needed to use the url below

http://localhost/jobs/85345-Php-Developer-Required

What I don’t get is that I have already stored the


<id:\d+>

into variable


<id>

so why does replacing the ‘/’ with ‘-’

cause it to fail ??