Force route case |
[eluser]Billy Khan[/eluser]
I have a site that some users are starting to link to, they have changed the case of some links which is ending up with page not found errors. I have trawled this forum and cant seem to find a solution. Ideally, i would like to get CI to ignore uri case. I can see that routes.php can handle regular expressions. But i am unsure as to how to make use of it. e.g. $route['news'] = "c_news"; Yet www.mysite.com/NEWS is breaking and is calling my default controller. any ideas?
[eluser]xwero[/eluser]
from a SEO point of view this is a good thing because it prevents plummeting your pagerank because of double content. So i think the request for case insensitive uri routing is not a going to stick. The routing is nothing more than a hidden preg_replace so if you do Code: $route[’news|NEWS’] = “c_news”;
[eluser]Billy Khan[/eluser]
Thanks. What about mix case? , e.g. www.mysite.com/News Would i need to put one in for all? e.g. $route[’news|NEWS|News|NEWs’] = “c_news”; I know some mix case examples are highly unlikely but i want to cover all bases.
[eluser]xwero[/eluser]
you can do Code: $route[sql_regcase('news')] = 'c_news'; So you could either use the function or just add the expression as your route key.
[eluser]xwero[/eluser]
the function is handy in this situation because you can't do /news/i. I stumbled on it looking for a solution for other regex problems
[eluser]Unknown[/eluser]
That saved a few hours of work. Thanks for posting.
[eluser]toltmanns[/eluser]
Seems like the solution to use sql_regcase() is no longer viable, as the function is now deprecated. |
Welcome Guest, Not a member yet? Register Sign In |