Question About Urlmanager Rules Regarding Id

Hello everyone,

First of all, I want to thank the creators of Yii for making such a great framework.

I have a (maybe silly) question about the URL rules.


'urlManager'=>array(

			'urlFormat'=>'path',

			'showScriptName'=>false,

			'rules'=>array(

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

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

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

				'login/'=>'site/login',

				'rss/'=>'collection/rss',

				'over-budgetkar/'=>'page/view/1',

				'neem-contact-op/'=>'page/view/2',

				'bekijk-de-instructies'=>'page/view/3',

				'b-of-be-rijbewijs'=>'page/view/4',

			),

		),

A rule like “‘login/’=>‘site/login’,” works perfectly, but if I want to map e.g. ‘page/view/1’ to ‘over-budgetkar’, it isn’t working. I get a 400 http error. Do you see what I’m doing wrong and do you known an answer?

Many thanks in advance.

Assuming that your action signature is something like


public function actionView($id)

the rule may look like this:


'over-budgetkar' => array('page/view', 'defaultParams' => array('id' => 1)),

You can read more on that right here.

Thank you very much, this is indeed the right solution.