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/myfolder-sample-URL.html
=>
http://mydomain.com/myfolder-sample-url.html
http://mydomain.com/myfolder-sample-url.HTML
=>
http://mydomain.com/myfolder-sample-url.html
but will do nothing for these URLs:
http://mydomain.com/myfolder-sample-url.html?say=MEOW
http://MYDOMAIN.com/myfolder-sample-url.html
If you want to restrict it to .html files only:
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule ^.+\.html$ ${lc:%{REQUEST_URI}} [NC,R=301,L]
Where to place: I would place it after domain name redirect rule:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule (.*) http://mydomain.com/$1 [L,R=301]
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule . ${lc:%{REQUEST_URI}} [R=301,L]
# your other rules
I also recommend using rel="canonical" links:
<link rel="canonical" href="PROPER_URL_HERE" />
If you do not need redirect, but rather ability to serve the file regardless of the file name case (case insensitive file names), then you can use mod_spelling ( http://httpd.apache.org/docs/current/mod/mod_speling.html ) and CheckCaseOnly On
directive.