Fix Your Permanent Redirect To Optimize Your Blog SEO

by

The following website URL’s may seem like they are the same page to you, but to a search engine they might actually seem like two different pages:

http://yourblog.com

http://www.yourblog.com

Search engines may think www.yourblog.com and yourblog.com are two different blog sites. You should set up a permanent redirect (technically called a “301 redirect”) between these sites. Once you do that, you will get full search engine credit for your work on these blog sites and it will improve your search engine optimization and the SEO rankings.

A simple edit in your index.php file in your blog root directory will fix the permanent redirect for you. This is the text you need to paste into your index.php (replace “yourblog” with your blog URL without .com). So for http://www.yourblog.com you would only write yourblog as seen below:

// non-www redirect
if (strstr($_SERVER['SCRIPT_URI'], “http://yourblog”) !== false) {
$newLocation = str_replace(“http://yourblog”, “http://www.yourblog”, $_SERVER['SCRIPT_URI']);
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: “.$newLocation);
}

When this is saved to your index.php, all your visitors will be redirected to www.yourblog.com even if they enter yourblog.com in their browser address bar.

As I have mentioned before you should add your blog to Google Webmaster Tools. There you can confirm this permanent redirect directly with Google.

Login to your Google Webmaster Tools account, go into “Tools” and choose “Set Preferred Domain”. There you can associate a preferred domain with your blog site, to always or never show the leading “www.” in Google’s search results.

If you liked this article, you may also like:

Time to Stop Reading and Start Blogging

Start blogging with WordPress

I have experienced many wonderful benefits achieved by having a blog. It has made an amazing difference for me in my life and career.

You can do it too. It literally takes 5 minutes to have your blog up and running. Follow my step-by-step guide on how to install WordPress and start blogging today.

November 2, 2008

Previous post:

Next post: