If you are on Apache 2.4 then in .htaccess you can use mod_rewrite with an Apache expression in a RewriteCond directive to make use of the tolower() function.
For example, the following will need to go near the top of your .htaccess file:
This redirects/corrects any URL containing uppercase letters to the same - all lowercase - URL.
The RewriteRulepattern[A-Z] simply checks there is at least one uppercase letter in the requested URL-path. The RewriteCond directive then calls the tolower() function on the URL-path (REQUEST_URI server variable) the result of which is then effectively captured using the regex /(.*)/.
The %1 backreference in the substitution string then holds the result of the tolower() function call (as stored by the capturing group in the preceding condition), ie. the lowercase'd URL-path.
Test first with a 302 (temporary) redirect to avoid potential caching issues and only change to a 301 (permanent) when you are sure it's working OK. 301s are cached persistently by the browser so can making testing problematic.
In .htaccess
Tested, works, if you have the mod_speling enabled.
Or, in a serverwide httpd.conf:
From: http://www.chrisabernethy.com/force-lower-case-urls-with-mod_rewrite/
If you are on Apache 2.4 then in
.htaccess
you can use mod_rewrite with an Apache expression in aRewriteCond
directive to make use of thetolower()
function.For example, the following will need to go near the top of your
.htaccess
file:This redirects/corrects any URL containing uppercase letters to the same - all lowercase - URL.
The
RewriteRule
pattern[A-Z]
simply checks there is at least one uppercase letter in the requested URL-path. TheRewriteCond
directive then calls thetolower()
function on the URL-path (REQUEST_URI
server variable) the result of which is then effectively captured using the regex/(.*)/
.The
%1
backreference in the substitution string then holds the result of thetolower()
function call (as stored by the capturing group in the preceding condition), ie. the lowercase'd URL-path.Test first with a 302 (temporary) redirect to avoid potential caching issues and only change to a 301 (permanent) when you are sure it's working OK. 301s are cached persistently by the browser so can making testing problematic.