There are many opinions on the choice of using www.domain.com or just domain.com for you sites, which is better?  I’m now tending towards domain.com simply because it shorter and the www doesn’t add any value.

Regardless of the www or not decision, of more importance is URL canonicalization.  Say what?   How about a Wikipedia definition:  `In computer science, canonicalization is a process for converting data that has more than one possible representation into a “standard” canonical representation.’

So what does this mean for our web site?  As seen above we can choose domain.com or www.domain.com for our site.  Well how about those sites with blogs or CMS’s, they often have default pages at domain.com/index.php or www.domain.com/index.php.  So who cares?  We as human users we don’t really care as we equate all those URL’s as we are used to seeing them arrive at the same content, but search engines don’t see them as the same.  If you consider Google ranking, and you have not taken care to canonicalize your URL’s, your link popularity gets divided among these the URLs reducing your maximum possible pagerank.

To help avoid this issue redirect one of your URL’s to the other with a permanent (301) redirect.  This is easily done on apache servers by adding one of the groups of lines below to your root .htaccess (with the domain replaced of course):

RewriteEngine on

# no www to www version
RewriteCond %{HTTP_HOST} ^domain\.com$
RewriteRule ^(.*)$ “http\:\/\/www\.domain\.com/$1” [R=301,L]

OR

RewriteEngine on

# www to no www version
RewriteCond %{HTTP_HOST} ^www.domain\.com$
RewriteRule ^(.*)$ “http\:\/\/domain\.com/$1”  [R=301,L]

or, on many hosts you can use set-up redirects using cPanel which modifies the .htaccess for you.

NOTE: there is a program called isapi_rewrite available for IIS servers to do the same things as .htaccess.

Google webmaster tools has an option to select a canonical URL for your site which will help your page rank issues, but still does not avoid the issue of having two addresses for your site, which can trip up things like locally installed versions of WordPress which have the URL coded in the settings.