5ubliminal@twitter

Why Is Google Case-Sensitive About URLs? : 5ubliminal's TellinYa

<a href="http://www.tellinya.com/art2/168/">Why Is Google Case-Sensitive About URLs? : 5ubliminal's TellinYa</a>
5ubliminal's YAMS
I noticed something disturbing …

I just bought a GPS unit (I'll tell you everything about it soon) and when doing some searches I noticed something peculiar when I disabled the filters and asked Google to show me everything.


Click the image for a larger version.

Duplicate content due to case-sensitive URLs.

Google has a duplicate content problem with case sensitive URLs. This is not a problem concerning specs but … this is somehow common sense issue. How can I tell others to link to me without altering the URL letters? Why would same address with different case be considered different? A street address with different case is different for any of you?

On the other hand not everybody is expert in .htaccess and can use .htaccess rules to fix this problem and Google should have taken the necessary steps and keep their index clean. I really think Google wants to have the biggest index and is willing to swallow any junk just to brag about the billions of non-unique indexed pages.

This matter is also discussed here by the WebMasterWorld fanatics and they live by the rules. Unfortunately the changing of the case in URL is not in reach of all webmasters and Google should look up to Microsoft and how they handle URLs and file paths.

How do you fix this issue on your site?

I have not found any easy fixes only at .htaccess level that would satisfy my needs for short and concise code but made a simple PHP workaround which consists of 2 changes. One to your .htaccess file:

# ReRoute Uppercase Containing URLs
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule ^(.*)$ lcaseurl\.php\?url=\/$1 [L,NC]

and the lcaseurl.php PHP file that needs to exist in the root folder of your website:

<?
// Check if URL is passed as parameter
if(strlen($_GET['url'])){
    
// Redirect to the lower-case version permanently
    
header("HTTP/1.0 301 Resource Moved Permanently");
    
header("Location: ".strtolower($_GET['url'])."");
    exit();
}
// If not URL passed return a 404
header("HTTP/1.1 404 Not Found");
?>

The above …

… will redirect any URL containing upper-case characters to the lower cased version and help Google keep the index cleaner and the page count of your site a little more towards its real value.

PS: To see this trick in action capitalize some letters in the address bar and hit enter. See how it will change back to lower-case.

5 Comments Posted By Readers :

Add your comment
#1 Seb Duggan from Great Britain web
Posted on Monday, 05 November, 2007
Your php method seems a little like overkill - there is a very neat way of doing this just in the htaccess file.

The regex escape character L forces everything after it to lower case; so you simply need to use the following:

RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule ^(.*)$ L$1 [L]
#2 Seb Duggan from Great Britain web
Posted on Monday, 05 November, 2007
That should read:

RewriteRule ^(.*)$ L$1 [L,R=301]

...to get the permanent redirection.
#3 Jeff Johnson from United States
Posted on Tuesday, 01 April, 2008
That RewriteRule does not work. Where is that L prefix documented?
#4 5ubliminal web
Posted on Tuesday, 01 April, 2008
L is supposed to be RegExp. I haven't tried it as I do it in PHP. But I'll check it out as I've seen it elsewhere too.
But the rule must look like this ^[A-Z]+$
#5 software-web from Italy web
Posted on Saturday, 06 December, 2008
Thanks a lot. I 've got the same problem in my asp.net Web Site.
You gave me a good idea where to start...hope i can fix it!!..
Then i'll insert the solution in these comment hoping canbe useful to someone..
Post Feedback 
Name *
Mail *
URL
« Anti-Spam
» URL will only go live after a review. Comments are moderated. «
5ubliminal's TellinYa.com SEM & SEO Blog © 2007 - All rights reserved unless mentioned otherwise .
Rendered On : [Tuesday, 06 January, 2009 - 01:20:54 GMT]   No Ajax / Flash Used Here
" Why Is Google Case-Sensitive About URLs? : 5ubliminal's TellinYa "
Close
Tellinya.com is relocating to blog.5ubliminal.com