Url Manager

My URL manager has following rules coz of which gii is not working


	'urlManager'=>array(

		'urlFormat'=>'path',

		'showScriptName'=>false,

		'rules'=>array(

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

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

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

		),

	),



How do i whitelist gii and anything else in the core like this.

Also is there a way i can force url’s to be all lower case. i.e if i enter any url(controller and action only) in any case other than all lowercase it needs to throw 404. My controllers are of format BlogPost and methods are of format actionChangepassword

Hi awebdeveloper

what exactly you want with gii?

for the second issue you can use [a-z0-9]+ rather than \w+


'<controller:[a-z0-9]+>/<action:\[a-z0-9]+>/<param:[a-z0-9]+>/*'=>'<controller>/<action>',

'<controller:[a-z0-9]+>/<action:[a-z0-9]+>/<param:[a-z0-9]+>'=>'<controller>/<action>',                           

'<controller:[a-z0-9]+>/<action:[a-z0-9]+>'=>'<controller>/<action>',

Thanks for the quick reply… because of url manager gii is not working.


Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects. 

. I removed all rules, gii works also if i make params to int, gii works

I just tried your rules they still accept all case

Try add those rules to the array:





                'gii'=>'gii',

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

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



Thanks gii now works like a charm… what about part 2 of the question

Try the slugBehavior (extensions) that should force the urls to be lowercase.

I think it would be a waste of time to try to do this by means of the UrlManager and/or server rules.

isn’t there any simple way i just want to force controller and view to be lowercase but actual names are camel cased

The rules I had post is only for lower letters cases (for all controller/action/param that roots to r=controller/action&param=…)

for gii issue the solution has posted by jacmoe

You can route it manually, but if you want to lead an easy life, name your controller methods/functions properly and let Yii generate nice lowercase urls for you. :)

I didn’t get you. To re-clarify my problem.

My controller names are of the form BlogPost and method names are of the form actionPopularposts but Yii accepts

  • blogpost/popularposts

  • blogPost/popularposts

  • BlogPost/popularposts

etc

I want it to only accept the 1st one others need to throw 404

You can try this:




'urlManager'=>array(


    (...other configuration...)


    'useStrictParsing'=>true