When working on a new website, most developers probably won’t be aware that http://example.com differs from http://www.example.com from Google’s point of view. Your website’s domain – while unique in itself – doesn’t automatically ensure that multiple URLs with the same homepage content are indexed as one by Google.
Consolidating multiple URLs into one preferred domain helps Google identify the URL structure of your website in a singular, non-duplicative manner and helps improve link and ranking signals for your website through proper indexing.
This also ensures that when external links direct back to your website, your preferred domain is automatically selected by Google. So if for example you have set your preferred domain to http://www.example.com, whether http://www.example.com or http://example.com/index.html is the format of the external hyperlink, Google will automatically regard it as http://www.example.com - your preferred domain URL.
So how do you let Google know your Preferred Domain? Simple, you simply need to log into your website’s Google Webmaster Tools, click the Setting icon (the gear), click Site Settings and enter your URL in the Preferred Domain field. Google may ask you to verify both www and non-www versions of the domain, and you should follow up this procedure with permanent 301 redirects from your ‘alias’ URLs to your primary, chosen URL.
Here’s Google’s Help Topic on how to set your preferred domain. This is a small but important step to keep in mind during SEO. It helps Google correctly consolidate your entire website and index its contents.
To achieve the same effect for other search engines, setting the preferred domain method is replaced by the use of canonical tags, aka canonicalization. To implement canonicalization, simply add the rel=canonical= tag to the HTML header of the ‘duplicate’ webpage.
So for example,
<link href="http://www.example.com/canonical_page/" rel="canonical" />
Would tell search engines that the given page should be treated as a copy of the URL http://www.example.com/canonical_page/ and that all credibility should be bestowed upon that page.