Wed 12 Nov 2008
I wrote a post awhile back on how to do case insensitive routing in CakePHP. The method described there doesn’t work anymore. The Cake Router now interprets the “:” character as the beginning of a named parameter.
An alternate way, which does work in RC3 is to begin your route with (?i), which will tell the regular expression engine to ignore the case for all characters to the right.
If you want to have an “about” page that is linked to by “/about”, “/About”, or “/aBoUt” you can use:
Router::connect(’/(?i)about’, array(’controller’ => ‘pages’, ‘action’ =>’display’, ‘about’));
I don’t believe there is way to set this for all routes, but if there is I would love to hear it.
Popularity: 9% [?]










Follow!
Email!
November 13th, 2008 at 1:13 am
[...] Case Insensitive Routes In CakePHP 1.2RC3 :: PseudoCoder.com [...]
November 13th, 2008 at 1:20 am
Shouldn’t this be a flag or a setting one would be able to set for the Router? It only makes sense that the routes should be case-insensitive. Such a flag should have existed a long time ago but with the option to enable case-sensitive routes.
Though, why would one prefer a case-sensitive approach is beyond me…
November 13th, 2008 at 2:33 am
Very usefull!!! Thnx Matt