Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Case sensitive URLs - how to make them insensitive?

I'm struggling with mod_rewrite and .htaccess... All I need to do is make my URLs case in-sensitive. After couple of 500 internal server errors and a lot of googling a lot of stack overflowing I'm just looking for one working solution.

NOT working: Convert to lowercase in a mod_rewrite rule

RewriteMap tolower int:tolower
RewriteRule  ^([^/]+)/?$  somedir/${tolower:$1}

NOT working: Case Insensitive URLs with mod_rewrite

CheckSpelling on

All I need is simple not-case sensitive URLs :)

like image 726
Mars Robertson Avatar asked Jul 27 '11 23:07

Mars Robertson


1 Answers

The following should work:

    <IfModule mod_rewrite.c>
    RewriteEngine on
    rewritemap lowercase int:tolower
    RewriteCond $1 [A-Z]
    RewriteRule ^/(.*)$ /${lowercase:$1} [R=301,L] 
    </IfModule>

If not, can you describe what's not working about the proposed solutions?

like image 64
Drizzit12 Avatar answered Sep 30 '22 20:09

Drizzit12