Eliminate PageRank penalties, redirect to either www/no-www

What? If my title isn’t clear enough, what I mean is redirecting a website from www.domainname.com to just domainname.com or vice-versa.

The Problem: You may wonder why? Well, the truth is 5 months back even I did. And I realised the importance of this only when I saw that www.blog.xabhishek.com had a pagerank of 1, blog.xabhishek.com had a pagerank of 5 and at the sametime xabhishek.com/blog had a pagerank of 0. For bird-brained humans who still didn’t understand, I’d just like to explain that search engines penalise you for having different URLs to the same content. So you’ve got to choose between having and not having the www prefix and should never have both at the same time, which in many cases is the reason people lose their pagerank.

Unfortunately the solution to this problem only works if you’ve actually hosted your blog/site on a server and wont work even if you’re using Blogger’s Custom Domain service. But if you publish via ftp, there is no reason this shouldn’t work.

The SOLUTION:

Open the .htaccess file(in the root folder of your website), and edit it to make appropriate changes as given below. Just add the the lines in bold to the .htaccess file if it already exists, but if you’re going to create the file, then use the complete text given below either Solution A or Solution B.

Solution A (Use this to redirect domainname.com to www.domainname.com) RewriteEngine On RewriteBase / *RewriteCond %{HTTP_HOST} !^www.domainname.com$ [NC] RewriteRule ^(.)$ http://www.domainname.com/$1 [L,R=301]**

Solution B(Use this to redirect www.domainname.com to domainname.com) RewriteEngine On RewriteBase / *RewriteCond %{HTTP_HOST} !^domainname.com$ [NC] RewriteRule ^(.)$ http://domainname.com/$1 [L,R=301]**

That explanation was as simple as it could be. Make sure you replace domainname.com with your domain name. If you want the technical info, you can find it on the Google.