Archive for December, 2012

Mode rewrite | No Comments | December 13th, 2012

To implement such redirect using mod_rewrite and .htaccess you need to use RewriteMap directive which cannot be placed in .htaccess — only in server config / VirtualHost context. If you have such access:

1. Place this line inside <VirtualHost> block for your site:

RewriteMap lc int:tolower
2. Place this in your .htaccess:

RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule . ${lc:%{REQUEST_URI}} [R=301,L]
This will redirect (301 Permanent Redirect) any URL that has at least 1 capital letter (Latin letters only) in path part of URL (query string is ignored) to the same but in lower case.

For example:

http://mydomain.com/myname-URL.html
=>
http://mydomain.com/myname-url.html

http://mydomain.com/myname-url.HTML
=>
http://mydomain.com/myname-url.html