Search Engine Friendly Redirects

While we talk a lot about how you should build your blog for people not search engines, of course many bloggers do want to get lots of search traffic. This post will help you fix common mistakes that causes Google to stumble on your content.

There are two problems with Google that have frustrated webmasters for a little while.

The first is the issue where Google sees links to and and thinks they are two sites with duplicated content. And Google doesn’t like duplicate content, oh no it doesn’t. D’oh!

If someone wants to create problems for your blog or website they can just link to the version of your URL that you do not commonly use. This can get you indexed and cause you problems. No guarantees but do you want to take the risk?

Another way a competitor can cause you problems is to use a temporary redirect to link to your content. In many cases these are put in place perfectly innocently, they are easier on many platforms than permanent redirects and are often done just to count clicks. Problem is Google can see the redirecting site as owning the content (and therefore the rankings) rather than the target site. D’oh again.

The solution to both is to use permanent redirects.

If you are moving a blog from one site to another, or just changing the folder structure, perhaps a blog software change, you need to put in place permanent redirects too. This tells search engine spiders that they should treat inbound links to the old URLs as valid links to the new URLs. As you know, links are important in search rankings so you want to keep as many as possible.

301 permanent redirect in .htaccess

If you use Apache then you should be able to redirect using your .htaccess file. Now, being a Microsoft fanboy I am not too much of an expert in the old Apache business but even I can manage this little bit of magic, here is the code to use

RewriteCond %{HTTP_HOST} ^
RewriteRule (.*)$1 [R=301,L]

This redirects using a 301 permanent redirect any request for the www. version to the non-www version of the URL. Just replace with your domain name.

PHP 301 permanent redirect

PHP can perform permanent redirects too by sending the 301 moved permanently header.

If you want to redirect a single page you just need the two header lines and change the location: URL to your target.


This is a “just the facts” summary of the issues, you can read more about the Google problem at threadwatch, stuntdubl has a list of more articles on performing redirects on his blog.