Canonical URLs and how to avoid them using redirects.

2007 April 28
by Barry

Sometimes if domains are incorrectly setup, the domain urls www.domain.com and domain.com are considered by search engines as separate pages. As both pages are indexed by search engines, you may be penalised for duplicate content (bad).

To avoid this, you can redirect all traffic to one standard URL, a canonical URL. Canonical means ‘standard’ or ‘authoritative’

I’ve implemented two simple methods around this.

1. Mod Rewrite in .htaccess

This is apache server specific, create or amend your .htaccess file with

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

This enables the Rewrite Engine (line1) while a condition on line2 comes into play when people access barryhand.com , this is also case sensitive [NC]

The 3rd line redirects to www.barryhand.com using a permanent 301 redirect

2. Google Preferred Domain

Google allows you to control your preferred domain from their excellent webmaster tools section. A whole host of goodies and stats are also available once you verify your site ownership.

Enabling both these methods will assist in search engine optimisation , for more information see here -

I'd LOVE if you shared this:
Talk to me on Twitter!

I'm @barryhand on Twitter.
Talk to me, that's how I find people to follow :)
Click here to find me on Twitter.

No comments yet

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS

blog comments powered by Disqus