CodeIgniter Forums
Forcing lower case controller names - 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: Forcing lower case controller names (/showthread.php?tid=8507)



Forcing lower case controller names - El Forum - 05-20-2008

[eluser]liquid_t[/eluser]
I just stumbled upon a problem with my site were people are linking to pages with the controller name in caps and getting 404 pages..not good Sad

For instance www.domain.com/contact is fine. www.domain.com/CONTACT is not. also I think this only happens with controller names. Not controller functions or their parameters.

So the question is: Can I force lowercase with routing or htaccess ... or something?

Thanks a lot!


Forcing lower case controller names - El Forum - 05-20-2008

[eluser]Mirage[/eluser]
I think this may have to do with your hosting filesystem being case sensitive. I develop on OSX/hfs and it is not. In the past I hosted on XServe so it was never a problem until I moved hosting to Linux and stuff started being a problem. I ended extending the Loader (and maybe some related classes) to relax the CI enforced naming rules. The only rule is now: You call it what you name it.


Forcing lower case controller names - El Forum - 05-20-2008

[eluser]Dam1an[/eluser]
One way around this (which I havn't tested, so may not work, but is worth a try, is creating a rule in config/routes.php for any uppercase string, something like
$route['([A-Za-z0-9]*)/('] = "strtolower($1)";

This should match any controller name which has upper case characters in it, and convert it to lowercase

Let me know if it works