.htaccess rewrite case-insensitive
I came across a little bug the other day working with htaccess redirects.
I was trying to figure out redirects using the RewriteRule but found that the redirect only works if the rule is written in the same case as the redirect. For example :
RewriteRule Admin/ index.php
( if i type admin in the browser the redirect would 404 ).
After looking into the apache manual i found the no-case flag
‘nocase|NC’(no case)
This makes the Pattern case-insensitive, i.e., there is no difference between ‘A-Z’ and ‘a-z’ when Pattern is matched against the current URL.
The above rule could then be coded as :
RewriteRule Admin/ index.php [NC]
Quite a nice feature i wasn’t aware of.
0 Comments