More Info »
Domain names and duplicate content
Google webmaster tools and preferred domain
Google webmaster help says: "To gain more control over how your URLs appear in search results, and to consolidate properties, such as link popularity, we recommend that you pick a canonical (preferred) URL as the preferred version of the page".
Sentence above is important, not only for Google, for other search engines too. "www.yoursite.com" and "yoursite.com" (without www) are two different websites, although there is the same content. Then, we are talking about duplicate content, two version of the same web page under different url.
Also, links from other websites are sometimes with www, and sometimes without www. Search engine spiders are following those links and your website content is indexed under two version of the same domain (www and without www). Another problem is that links to www and non www version are diluting PageRank, importance of page.
How to set preferred domain in Google webmaster tools
Say that you have already www.yoursite.com added. To set preferred domain to www.yoursite.com, you need to add yoursite.com too and verify ownership. You don't need to upload verification file again (or add tag), just click "verify" and it is done. Now you can set preferred domain (www or without www).
What about "missing backlinks" in GWT
In many web forums webmasters are complaining that Google webmaster tools (GWT) not shows all backlinks. Check links to the second version of website. You will probably find missing backlinks there. Believe or not, sometimes one version shows backlinks to main page only, while second version of domain shows backlinks to other web pages.
This could be sign of potential problem. It could show that google prefer version of your domain where links to main page are shown. In that case, if website is newer, avoid to mention non-preferred version of domain anywhere, including text (not linked). However, check number of backlinks to non-preferred version of domain from time to time, and compare.
How to set preferred domain on website
If preferred version of domain is set in webmaster tools, that doesn't mean that job is finished. For Google, it is good to add canonical tag on every page on website, not only to set preferred domain, to avoid duplicate content issue, when the same page is called with different parameters.
This tag must be added between <head> and </head>
<link rel="canonical" href="http://www.yoursite.com/">
That is for Google, this tag is still ignored from other search engines. For all search engines and for visitors and theirs browsers, 301 (permanent redirect) is the best solution.
How to redirect domain using htaccess
This is already explained in redirect domain using htaccess guide with more details, anyway here is again.
Add following to your htaccess:
Non-WWW to WWW version:
WWW to non-WWW version:
Below is modified non-WWW to WWW version I am using:
Means: If it is NOT WWW version, redirect to WWW version
Base Href tag
According to my experience, no help from base href tag in this case. It is useful to partially protect website content from scrapers, here is the link to that guide: how to protect web page content
Redirect to preferred domain using PHP
While htaccess redirection is for a whole website, PHP example below is for individual page and it must be placed on top of page (no spaces before opening tag)
Non-WWW to WWW version
WWW to non-WWW version
Don't forget to replace yourdomain.com with your domain name.
Content on this Web site is © AffiliateBeginnersGuideDotCom
Do not copy, link to this page.