Friday, August 15, 2014

Tips to Resolve Website Canonical Issues - WWW and Non-WWW

I wouldn't believe it if it didn't happen to my sites - a few sites. In the last two months, I noticed Google didn't crawl my sites daily like before, the pages got de-indexed quickly, the rankings also dropped to nowhere. I thought it was caused by the changes of Google's ranking algorithm and didn't look into it. Today, I found an index page wasn't cached by Google, I feel something is really wrong here.

After some checking, I found it was caused by the links pointing to the non-www verson. This topic has been discussed a lot on the webmaster forums, but I didn't get it without examples. I didn't believe Google had such a silly problem either.

See an Example

It can be accessed with http://www.xwz.com/ or http://xwz.com/. I always promote my sites with www version. But if someone links to this blog with http://seoblog.us/, Google treats xwz.com and www.xwz.com as two different sites and will dump out www.xwz.com because of duplicated content. Very hard to believe? It's that that simple, that silly.

As now, I have at least 5 sites ( around one year old) which lost the most pages including their index pages. Since the majority links point to www version, the non-www version has very poor ranking. I can't find the links pointing to non-www version, I guess they are only a few, I can't understand why Google dumps out the www version which has hundreds of links. This is the worst thing happened to my websites since I was a webmaster, I have to say it is the silliest thing about the search engines I have ever heard.

You can read more details about this problem here, also many discussions.

This problem can be fixed by redirecting one url to the other one. I used .htaccess, see below example

Solution for Canonical Issues

1. Create a text file named ".htaccess" with the following content, place it under the root directory.

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

If you have .htaccess under sub-directories, it should be modified accordingly.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^xwz.com
RewriteRule (.*) http://www.xwz.com/forums/$1 [R=301,L]

Sub-domains are like this:

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

0 comments:

Post a Comment