A Short Case Study on Redirects: 301s vs. 302s

January 5, 2009

When I moved to this site a couple of months ago and redirected the old blog to this one, I experienced the joys and sorrows that we all do when we move sites. I was redirecting at several levels. From the .htaccess file of the old site, I was doing a site-wide redirect. From the .htaccess file of the new site, I was redirecting from the old URL pattern to the new one (and from the non-www version to the www version). Wordpress itself was also redirecting, for instance, from the version of the URL without the slash to the version with it. Within .htaccess, some redirects use RedirectMatch, others use Redirect, and others are really URL rewrites using mod_rewrite.

I also redirected my feed using .htaccess and Feedburner, and am still sorting out how (and if you really can) redirect and consolidate (even if you’re using MyBrand).

There’s a lot going on and I intentionally unleashed it using all kinds of variations to see what would happen. For you. Surely someone will send me a cookie.

The difference between 301s and 302s

I have a whole set of notes that I’m writing up on all the different redirection options and what the pitfalls are, but for now, I wanted to illustrate the difference between a 301 and a 302. I am asked this a lot (“does it really make a difference?). It can get confusing, because although search engines say to use a 301 when moving a site (or page), server software tends to use a 302 as the default when you implement a generic redirect (without specifying if it should be a 301 or 302).

Some of the redirects for my site move were initially implemented as 302s and others as 301s, so I could see how things worked in real time.

A 302 is a “temporary” redirect

Search engines tend to interpret a 302 as an instruction to index the old URL but the new content. It keeps the old URL because the server has said that the new one is only “temporary”. You can see that here with a Google search for my name. As you can see, the URL is for the old site, but the title and description in the search result are from the new one.

A 301 is a “permanent” redirect

Search engines interpret a 301as an instruction to replace the old URL with the new one. As you can see, once I changed the redirect to 301, the new URL showed up in the place of the old one.

The new URL is ranking in the same location for the query [vanessa] as the old URL was, which implies that the links and anchor text that pointed to the old URL are now being transferred to the new URL. In addition, you might notice that the URL I’m redirecting my old home page to (www.ninebyblue.com/blog/) has a toolbar PageRank of 6, while the home page of this site (www.ninebyblue.com) has a toolbar PageRank of 4, so at least in terms of visible toolbar PageRank, that credit is passed via the 301 as well.

Should you use a 301 or 302?

As you can see, for a permanent site (or page) move (and to consolidate duplicate pages), a 301 is the way to go, and you should check with the details of your implementation to make sure that your redirect really is happening via 301.

For more details:

Learn more up close and personal!

If you’re geeky like me, and want more techie stuff, come on out to SMX West Developer Day in February or the O’Reilly Found conference in June! Both are shaping up to be quite geeky, and by that I mean, very fun.

18 Comments

Timely post. I was researching just this thing for a sports blog I moved! Thanks!

“Surely someone will send me a cookie.”

But you travel so much–if we send you cookies, who will forward the cookies to you as you hop around the country? How do we know these redirectors won’t just eat the cookies themselves? It could take months to concoct an experiment to determine the optimum address + packaging scheme most likely to have the cookies reach your location.

According to dopplr, I only had 42 trips last year! Oh wait… On second thought, you’re probably right. If you hold on to those cookies, I’ll likely end up in the same town as they are sooner than if you were to send them.

I concur on the timeliness of this post as I am struggling with this very issue on behalf of a client who plans to launch a site in a temporary location until the permanent home can be built out. My Pavlovian response was to dictate the 301 redirect. Yet, after reading this post, I see that a 302 is an option. My concern is that while both locations will hang off a firmly entrenched domain, these will be new subdirectories with brand new content.

marianne, they can’t build out the temporary content in the same location as where they’ll put the permanent home?

If I’m understanding you correctly, you have something like:

site.com —————> main site
site.com/permanent —–> permanent location of new content
site.com/temporary —–> temporary location of new content

And while the /permanent URLs can be live right away, the content has to live at /temporary initially.

So you were originally thinking of doing a 301 from /permanent to /temporary until you were able to use the permanent home and then removing the 301 from /permanent and adding a new 301 redirect from /temporary to /permanent?

Can you add more details about the situation?

“You can see that here with a Google search for my name. As you can see, the URL is for the old site, but the title and description in the search result are from the new one.”

>>> Do you mean it’s showing vanessafoxnude.com? I just searched for your name ‘Vanessa Fox’ and it shows http://www.ninebyblue.com/blog URL.

On second thought, even if it showed the vfn.com, it might be because the algos consider a single nude vanessa fox to be better (result) than nine blue ones.

Affan, when the redirect was a 302, Google was displaying vanessafoxnude.com, as you can see from the first screenshot. Once I changed the redirect to a 301, Google started showing ninebyblue.com, as you can see from the second screenshot.

As for the algorithm figuring out which is a better result, vanessafoxnude.com doesn’t exist anymore. It’s been replaced with ninebyblue. And the 301 redirect lets the search engines know that, and thus the algorithms as tailored to use that factor when determining what the best result is. A non-existent site is never the best result.

Thanks for the illustration, Vanessa.

This topic’s been expected since my previous comments on your site moving.

How about the Meta Refresh Tag with Time=0s? Is it considered a 301 like this illustration?

http://dunguyen.com/blog/redirect-illustration-301-vs-302-vs-meta-refresh-vs-javascript-redirects/

BTW, do you take notes on the time of the old site completely removed in Google SERPs when using 301? For your old site, I still see 4 URLs indexed (with a very good ppt file on Blog SEO hehe). I did use 301 to redirect from www to non-www some months ago but now some www-URLs are still indexed. Seems that we cannot control this. Hmm…

Sorry I missed the screenshots first having turned images off. But the algos figuring out comment had something b/w the lines though I probably made it too serious!

Anyway, since you mentioned you are writing more notes on redirection options, I would be grateful if you can touch on the following in any future post:

1) Does it affect a site’s credibility or the organic rankings in anyway if there are too many redirects. Like I guess you have redirected all blog posts on the old domain to this new one. So though it may take time to bring the rankings back, but do you think all these redirects have any combined negative effect just because you redirect too many pages.

2) If there’s a new large site that doesn’t have any backlinks and no visitors yet, and they decide to either change the domain or want to optimize and rewrite URLs; would it be better for them to 301 redirect all previous pages to new ones (large site may mean 500+ pages), or should they skip the redirect and just put the pages on the new domain/URL since they don’t have any links or traffic yet?

Thanks for your time.

Vanessa,

I have a blog with 100 posts. Now I would like to move the entire content to new url like what you did. In those 100 posts few posts are ranked well in search engines. If I would apply simply the 301 redirect to all my posts then “Does the search engine rankings will remain the same?”. It means “Does the old post url will replace by the new url in the search engine results with the same position?”.

If your answer is yes. I am happy.

If your answer is no then please let me know what else needs to be done to get those positions with the new url.

Thanks in advance

When you say “search engines,” have you included Yahoo within your analysis? For my client’s site, the 302 redirect in Yahoo does not function the same way it does in Google. In fact, Yahoo never picked up the new site. Thoughts?

I was very confused about 301 and 302 redirection. Now things seems to be very clear. I hope you will keep on making such good articles which are useful to me.. :)
That was nice.. thanks..

Hi Vanessa,
may I suggest my book on redirects for addition to your ressource section above? It’s a bit technical, but comprehensive.
Thanks and have a great new year!
Sebastian

Vanessa, I was going to send you a cookie but before I do, I need to know, do you accept 3rd party cookies or do I have to make it myself?

I’d hate to go out and buy some fancy vampire cookie (http://bakingbites.com/2008/10/vampire-cookies/) and send it to you only to have it rejected because you’ve set your privacy settings to reject 3rd party cookies.

So if it turns out that I have to make it myself, let me know…

On another note, kudos for the CNN snippet (though personally I thought they ranted way too much, didn’t include more from you and clearly CNN would have had a much higher unique visitor count today had they mentioned your name in the article headline…

[...] of Vanessa, she provided us with a nice illustration of a 302 vs. 301 and what not to do in social media. Poor Yelp. I like [...]

*** I was redirecting at several levels. From the .htaccess file of the old site, I was doing a site-wide redirect. From the .htaccess file of the new site, I was redirecting from the old URL pattern to the new one (and from the non-www version to the www version). Wordpress itself was also redirecting, for instance, from the version of the URL without the slash to the version with it. ***

For some URL request formats it looks like the browser might hit a Redirection Chain of up to four steps. This can be quite dangerous. PageRank isn’t passed through anything more than a single-step redirect.

It is best to craft the rules so that the most specific rules are listed first and they also fix all the other problems (for that URL) that the later rules also fix. That will mean that for any URL request, the target URL will be reached in just one hop.

*** Within .htaccess, some redirects use RedirectMatch, others use Redirect, and others are really URL rewrites using mod_rewrite. ***

If directives from Mod_Alias and Mod_Rewrite are included within the same .htaccess file, then you cannot guarantee the order that they will be processed. The processing order is the reverse of the order of module loading, as defined in the httpd.conf file. In some cases the server will do the internal rewrite first (so updating the internal path reference), and then a redirect will kick in and “expose” that internal filepath to the outside world in a new URL. That action can be a site killer.

If you need a mix of redirects and rewrites, it is best to use Mod_Rewrite for all of them. Make sure that you list the redirects first (in order, from most specific to most general), and the rewrites last (in order, from most specific to most general). In this way, there will be just one redirect acted on, and one rewrite if needed, for each URL requested.

g1smd, well part of the reason I’m doing it this way (or so many different ways) is to experiment and get real-life examples of what happens, since I think a lot of people move their sites in random ways like this. But also, I am not an .htaccess expert so your info is exactly what I’m looking to learn more about!

And I definitely always recommend that the number of hops in a redirect be minimized. But it’s a good experiment to see if your theory on PageRank not transferring with more than one holds true. :)

There’s a lot of non-obvious black art with this stuff, especially in deciding when to start- and end-anchor stuff, and exactly what format to use for patterns for matching wildcards.

Two rules of thumb:

1. “Just because it appears to work for the test URL, doesn’t mean it will work the way you want it to work for all the different URL formats that will be thrown at it in real life”.

2. “Error 500? – Only 499 to go”. (with thanks to jdMorgan at WebmasterWorld, for that one).

:-)

Leave a Reply

  • Nine By Fox

    Stories from the online marketing industry, Vanessa's travel adventures, and more. For reference material and analysis, see the Library.
  • Buy the Book!

  • Categories

  • The Latest From Twitter