How do I do a case-insensitive mod_rewrite redirect to the same URL (mod case)?
This depends on a few things in your web application, but you could:
- Use mod_speling to force the correct capitalization of filenames and directories. This requires "real" filenames.
- Use RewriteMap to rewrite the url (as seen here):
In .htaccess:
RewriteEngine on
RewriteBase /
RewriteMap insensitive tolower:
RewriteRule ^[\/]*(.*)$ /${insensitive:$1} [R,L]
First off, if you can use mod_speling that's easiest, but that requires actual files, not stuff hiding inside an application somehow.
Simply set a condition so the rewriterule doesn't happen if the request is capitalized properly, like so:
RewriteCond %{REQUEST_URI} !^/Your/File$
RewriteRule ^/your/file$ /Your/File [NC,R]