• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Forcing lower case controller names

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!

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.

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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.