I was just doing some tweaks to the blog in terms of SEO work and came up with a slightly different way to handle www/non-www versions of my blog. There are a few solutions that are out there and I just wanted to go over them for anyone who has not done this themselves. Before I start, you may be asking yourself what I am talking about so heres a quick overview of the “problem”.

To a reader, the following URLs may seem the same:
http://hatethegrind.com
http://www.hatethegrind.com
http://www.hatethegrind.com/index.php

However, to a search engine robot, those are three unique pages and as a result could have three different page ranks assigned to them. If you want all the backlinks associated with the three pages to all be counted towards the proper page, you will have to use some method to unify your website.

  • The first method is by using PHP (or any other server side scripting)
  • You need some code that will check whether or not “www” is in the URL. If not, add it and redirect the user to the new page using a 301 redirect.


    if(!stristr($_SERVER["HTTP_HOST"], 'www')){
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.hatethegrind.com" . $_SERVER["REQUEST_URI"]);
    exit();
    }
    ?>

  • The .htaccess method
  • Another way to accomplish this is to simply edit the .htaccess file on your webserver. By adding the following lines into your .htaccess file, you are essentially doing the same thing.


    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^hatethegrind\.com [NC]
    RewriteRule ^(.*)$ http://www.hatethegrind.com/$1 [R=301]

  • Google Webmaster Tools Preferred Domain
  • If you log into the Google webmaster tools, you’ll find an option to set a preferred domain for your website. This is probably the easiest way to have Google index your results properly but will not redirect your users to the proper page. In other words, users will still be able to access your blog through the various URLs, and they will not be redirected. Google will however, attribute page rank properly.

Whichever method you choose is up to you, and all three should work. After doing all this, there are additional steps to ensure your site linking is optimized. Be sure to always link to the version you prefer when linking to other pages within your site. Good luck, and happy tweaking!

Did you like this post? If so share with others: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Netscape
  • Reddit
  • del.icio.us
  • StumbleUpon
  • Digg


Other posts you may be interested in:

  • No related posts