duplicate uppercase lowercase google wordpress joomla

Htaccess fix for duplicate uppercase/capital letters in WordPress & Joomla

If you use Google Webmaster Tools to keep an eye on your website’s performance, you may have come across the problem of duplicate URLs being flagged as ‘not indexed’ due to Google picking up on URLs that are all lowercase when you create them, but somehow seeing some uppercase letters in there too. For example, you create a web page with the URL: www.mydomain.com/big-ben-london but somehow, you also see in Webmaster Tools: www.mydomain.com/big-ben-London Notice how Google has replaced the lowercase “l” with an “L” for London and is now reporting a problem to you.

This can become a long-term problem if you don’t fix it soon as Google now sees two versions of the same page. There are several ways to fix this but one of the easiest methods is to add some code to your .htaccess file to essentially rewrite all your problem pages. Whilst this issue isn’t exclusive to WordPress or Joomla, we’ve mentioned these two as they’re amongst the most popular out there. Ideally you should put this at the top of your .htaccess file and if not, certainly above any other rewrite rules that your .htaccess file contains

htaccess code to rewrite uppercase (capital) letters to all lowercase

Place this code at the top of your .htaccess file and it should solve your problem:

RewriteEngine On
RewriteBase /

# Start rewrite uppercase URLs to all lowercase
RewriteRule [A-Z] – [E=HASCAPS:TRUE,S=1]
RewriteRule ![A-Z] – [S=28]
RewriteRule ^([^A]*)A(.*)$ $1a$2
RewriteRule ^([^B]*)B(.*)$ $1b$2
RewriteRule ^([^C]*)C(.*)$ $1c$2
RewriteRule ^([^D]*)D(.*)$ $1d$2
RewriteRule ^([^E]*)E(.*)$ $1e$2
RewriteRule ^([^F]*)F(.*)$ $1f$2
RewriteRule ^([^G]*)G(.*)$ $1g$2
RewriteRule ^([^H]*)H(.*)$ $1h$2
RewriteRule ^([^I]*)I(.*)$ $1i$2
RewriteRule ^([^J]*)J(.*)$ $1j$2
RewriteRule ^([^K]*)K(.*)$ $1k$2
RewriteRule ^([^L]*)L(.*)$ $1l$2
RewriteRule ^([^M]*)M(.*)$ $1m$2
RewriteRule ^([^N]*)N(.*)$ $1n$2
RewriteRule ^([^O]*)O(.*)$ $1o$2
RewriteRule ^([^P]*)P(.*)$ $1p$2
RewriteRule ^([^Q]*)Q(.*)$ $1q$2
RewriteRule ^([^R]*)R(.*)$ $1r$2
RewriteRule ^([^S]*)S(.*)$ $1s$2
RewriteRule ^([^T]*)T(.*)$ $1t$2
RewriteRule ^([^U]*)U(.*)$ $1u$2
RewriteRule ^([^V]*)V(.*)$ $1v$2
RewriteRule ^([^W]*)W(.*)$ $1w$2
RewriteRule ^([^X]*)X(.*)$ $1x$2
RewriteRule ^([^Y]*)Y(.*)$ $1y$2
RewriteRule ^([^Z]*)Z(.*)$ $1z$2
RewriteRule [A-Z] – [N]
RewriteCond %{ENV:HASCAPS} TRUE
RewriteRule ^/?(.*) /$1 [R=301,L]
# End rewrite uppercase URLs to all lowercase

Now go and tell Google what you’ve done!