My status
Mar 22nd

Duplicate Home Pages – Canonicalization

written by: Lee Johnson

Site Construction – The Problem

When building a site there are certain SEO fundamentals that web designers often miss. This is understandable as search engines aren’t their specialist area; although many web designers now have a basic knowledge of SEO and know how to build a site that is search engine friendly.

One of the key SEO mistakes which designers miss is the creation of several home pages due to site navigation. The problem occurs due to the way search engines view sites, or more appropriately the way search engines view URLs. You see, although there is only one index (home) page on a server when that page is delivered to the end user it can appear in the address bar in a variety of different ways:

http://www.yourdomain.com

http://www.yourdomain.com/index.htm

http://yourdomain.com

http://yourdomain.com/index.htm

Each one of these URLs will pull the same file (index.htm) from the server. This is obvious to us, but to the search engines a different URL means a different page and it treats all four as independent pages from each other. This causes various problems with PageRank, duplicate content and spidering.

The Solution

There are various ways which we can solve this problem and all are very easy to setup. What we need to do is tell the server to always produce the correct URL no matter what is requested. We do this by using 301 redirects, htaccess and mod_rewrite’s.

You don’t need to be a programmer to do this, simply add the code below to your .htaccess file.

To redirect non www URLs to include the www use:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^ yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]

To redirect yourdomain.com/index.htm to yourdomain.com/ use:

RewriteEngine on
RewriteRule ^/index.(php|html)$ http://www.yourdomain.com/ [R=301, L]
RewriteRule ^(.*)/index.(php|html)$ http://www.yourdomain.com/$1/ [R=301, L]

Any internal site links and any external inbound links will now seamlessly redirect to one URL. This solves the problem but the lesson is… make sure the site is built correctly from the start!

Tags: ,

One Response to “Duplicate Home Pages – Canonicalization”

  1. Simon says:

    Hi, thanks for this, are you able to explain the difference between your code and this similar code I found elsewhere?

    RewriteCond %{THE_REQUEST} /index.php HTTP/
    RewriteRule ^index.php$ / [R=301,L]

    Does it achieve the same thing or is one better/worse?

    Thanks

Leave a Reply

You must be logged in to post a comment.