Yii framework case insensitive URLs

This is really a quick tip,

So sometimes we may want to treat our urls in case sensitive way, this applies to when you are hosting on Linux, and sometimes you want them to be treated the same regardless of the case

 

So what you need to do is to open your main.config file

and look for urlManager component.

by default this component is commented as shown below

  1. 'urlManager'=>array(
  2. 'urlFormat'=>'path',
  3. 'rules'=>array(
  4. '<controller:\w+>/<id:\d+>'=>'<controller>/view',
  5. '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
  6. '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
  7. ),
  8. ),

 

Now just after urlFormat item add another array item as shown below

  1. 'urlManager'=>array(
  2. 'urlFormat'=>'path',
  3. 'caseSensitive'=>false,
  4. 'rules'=>array(
  5. '<controller:\w+>/<id:\d+>'=>'<controller>/view',
  6. '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
  7. '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
  8. ),
  9. ),

Important bit above is introduction to caseSensitive setting above and setting its value to false. By default its true

 

I hope this helps

Cheers

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Speak Your Mind

*

CommentLuv badge