Force route case - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Force route case (/showthread.php?tid=9213) |
Force route case - El Forum - 06-17-2008 [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? Force route case - El Forum - 06-17-2008 [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”; Force route case - El Forum - 06-17-2008 [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. Force route case - El Forum - 06-17-2008 [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. Force route case - El Forum - 06-17-2008 [eluser]Billy Khan[/eluser] Worked a treat, many thanks! Force route case - El Forum - 06-17-2008 [eluser]wiredesignz[/eluser] Very clever Xwero Force route case - El Forum - 06-17-2008 [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 Force route case - El Forum - 09-10-2010 [eluser]Unknown[/eluser] That saved a few hours of work. Thanks for posting. Force route case - El Forum - 08-10-2011 [eluser]toltmanns[/eluser] Seems like the solution to use sql_regcase() is no longer viable, as the function is now deprecated. |