Redirection 301 and 302 and Google

301 and 302 http reply codes indicating redirections are very much different in terms of Google SEO. And did you know WordPress is always using 302 by default?

Let’s see what the difference is first.

301 :  Moved Permanently. 301 tells you that the current website requested by current URI is moved to a new brand new URI, so you should drop the originally used URI. If you are moving a website to a different domain, this is the way should be done.

302 : Moved Temporarily. 302 tells you that the current redirection is temporary  and you should use the original request URI next time you visit again. If you are temporarily redirecting to a page (site update or special product promotion…), this is it.

Now let’s see How Google sees these redirection codes. If 301 is used, Google will move original request URI’s PageRank to the new destination URI. And eventually remove the request URI. If 302 is used PageRank will be intact to the original website and the original website will also benefit from the destination website’s content.

Many shared webhosting accounts set up both www (ex. http://www.example.com )and top level domain (http://example.com) to point to the same webpage by default. If you use them both website URLs thinking they are the same address, you are mistaken. In fact, you will eventually split the PageRank and pages might be considered as duplicated content.

I had this WordPress website to promote. Let’s say it’s http://www.example.com. I found that when I checked the Search engine status and searched the domain, I domain name was ‘example.com’ instead of ‘www.example.com’.  I just couldn’t understand because I was promoting only using ‘www.example.com’ everywhere , but ‘example.com’ was cached by Google.

But then I remembered that I used ‘example.com’  during the first website development. I setup Google analytic code in the website, and used ‘example.com’ most of the times accessing the website. I think that made the ‘example.com’ as the primary or first URL to Google instead ‘www.example.com’

So I checked the HTTP header (This can be easily done by run curl or wget tool ) and when I used ‘example.com’ , the server replied with 302 code! So that’s why ‘example.com’ still lived in the Google Search Engine.

HTTP/1.1 302 Moved Temporarily
Date: Wed, 23 Sep 2009 12:30:32 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8i
X-Powered-By: PHP/5.2.9
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=c22b7be08ec5f5ee5c9238727b3eec3a; path=/
Location: http://www.example.com/
Content-Length: 0
Content-Type: text/html; charset=UTF-8

I quickly checked the WordPress PHP files and wp_redirect function’s default redirect code was 302. Solution was to enforce 301 redirection and I found this Permalink Redirect WordPress Plugin. In fact there are other redirection plugins out there , but this plugin is simple and easy to setup. Just enabled the ‘Hostname Redirect’ check box from the option page and it’s showing 301. Thanks Scott.

I hope this update will resolve the issue with Google search result. When you are thinking of permanent website redirection, make sure you use “301”.

Here are some more reading on 301 and 302 redirections.

http://en.wikipedia.org/wiki/URL_redirection
http://news.stepforth.com/blog/2008/01/redirects-permanent-301-vs-temporary.php
http://www.mattcutts.com/blog/seo-advice-url-canonicalization/
http://www.mattcutts.com/blog/seo-advice-discussing-302-redirects/

Here is an update. From Google Webmaster – Duplicate content and multiple site issues, there was a new introduction of link tag with ‘rel’ attribute that will help to correct and guide Google to move the destination website. Add below tag in the header in between <head> and </head>

<link rel="canonical" href="http://www.example.com"/>

Leave a Reply