Case insensitive 301 to same URL?

I searched the topics here and did not see this posted, and haven’t found an obvious solution on Google… it is bugging the heck out of me!
I have a situation where there is capitalization in URLs, and people are linking to them with mixed case URLs or people are typing it in the address bar directly.
There are thousands so I need to handle this in some sort of rewrite.

The current URL is
But in any number of iterations people are arriving at and getting a 404

The .htaccess is all set up it works great, just this one situation I need to resolve.

I need to detect anything that IS NOT in the exact case of and 301 it to that exact case URL.

I have tried RedirectMatch and several RewriteCond/RewriteRule but the closest I have come so far ends in an infinite 301 loop.

Is this something regular expressions could handle, and if so, any hints on what that solution might look like?

Thanks a lot!

Hi tentonjim,

You use the No Case Flags like

RewriteCond %{HTTP_HOST} !^www\\.my_domain\\.com[COLOR=#b22222] [NC][/COLOR] 


 RewriteCond %{HTTP_HOST} !^www. [COLOR=#b22222][NC][/COLOR] 

The no case flag ensures that the pattern is evaluated without case sensitivity.



The first thing to try is an Apache module named mod_spelling which corrects capitalization errors and minor typos. It’s NOT enabled by default but you could ask your host to enable it for you.

Lacking that, you could use mod_rewrite to find and replace every uppercase letter by its lower case equivalent - a nasty prospect at best. You can get sample code from my signature’s tutorial that will help you with that.

Whoops! You’re using mixed case file names? Horrors! If that’s the case, you’ll need the same “Poor Man’s RewriteMap” I just responded about in another thread but have it read the {REQUEST_FILENAME}, convert it to lower (or upper) case then, using an array for the required redirection, redirect to the CaMeL case you’re using.


The No Case flag works to MATCH CaMeL case (useful in your example with the {HTTP_HOST} but it will not change the case as Jim is requesting (of the {REQUEST_URI}). RewriteMap’s %[tolower] will do that (change all to lower, not guess where the CaMeL is :nono: ) but I believe that you can’t even use %[tolower] without enabling it in the httpd.conf.