Search code examples
urlmod-rewritecase-sensitivecodeigniter-2

Rewrite to case insensitive urls in CodeIgniter site?


I'm using CodeIgniter for a web application, and now I have an urgent question: I just discovered that urls are case sensitive in Linux based servers, and I have just moved a site from Windows to Linux. This means links to the site don't work anymore where there are now all lower-case urls, which were not before.

Googling I found that you should be able to do something like this in the .htaccess file:

RewriteMap  lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]

But I tried that and it was not good at all...! Suddenly I got a big ugly error page staring at me instead, saying that there must be something wrong with the Tomcat server or something like that. Needless to say I removed those lines immediately!

But why didn't it work then, and what should I do instead?

Any help would be greatly appreciated.


Solution

  • Actually found out that it was quite easy, surprised that no one answered this (perhaps it isn't the correct way, but I would think so...):

    I just added some routes in the routes.php file in the config folder:

    $route['About/Contact'] = "about/contact";

    And so on...