1. Computing

Discuss in my forum

What's the difference between 301 redirects and 302 redirects

When Should You Use 301 and 302 Server Redirects?

By

What is a Status Code?

Whenever a Web server does something to serve a Web page, a status code is generated and written to the log file for that Web server. The most common status code is "200" - which means the page or resource was found. The next most common status code is "404" - which means the requested resource was not found on the server.

When a page is redirected with a server-level redirect, one of the 300-level status codes is reported. The most common are 301 - permanent redirect and 302 - temporary redirect.

When Should You Use a 301 Redirect?

301 redirects are permanent. They mean that the page has moved, and they request any search engine or user agent coming to the page to update the URL in their database. This is the most common type of redirect that people should use.

But they don't use it. Instead they use the meta refresh tag or 302 server redirects. And this is a dangerous practice. Search engines don't like either of these redirection techniques because they are a common ploy for spammers to use to get more of their domains up in search engine results.

Another reason to use 301 redirects instead is that then your URLs maintain their link popularity. If you set up 302 redirects, Google and other sites that determine popularity ratings assume that the link is eventually going to be removed. After all, it's a temporary redirect. So the new page doesn't have any of the link popularity associated with the old page. It has to generate that popularity on its own.

Don't look like a spammer. If you're changing your site's domain name, you should definitely not use a 302 redirect. This almost screams "spammer" and is a good way to get all your domains blocked from Google and other search engines. If you have several domains that all need to point to the same place you should use the 301 server redirect. This is common practice for sites to buy additional domains with spelling errors (www.gooogle.com) or for other countries (www.symantec.co.uk), and then redirect them to the primary Web site. As long as you use a 301 redirect, you won't be penalized in search engines.

Why Would You Use a 302 Redirect?

The best reason to use a 302 redirect is to keep your ugly URLs from being indexed permanently by search engines. For example, if your site is built by a database, you might redirect your homepage from a URL like:

http://www.about.com/

To a URL with lots of parameters and session data on it, that would look like this:

(Note: The » symbol indicates a line wrap.)

http://www.about.com/home/redir/data? »
 sessionid=123478&id=3242032474734239437&ts=3339475

When a search engine picks up your home page URL, you want them to recognize that the long URL is the correct page, but not define that URL in their database. In other words, you want the search engine to have "http://www.about.com/" as your URL.

If you use a 302 server redirect, you can do that, and most search engines will accept that you're not a spammer.

What to Avoid When Using 302 Redirects

  1. Don't redirect to other domains. While this is certainly possible to do with a 302 redirect, it has the appearance of being much less permanent.
  2. Large numbers of redirects to the same page. This is exactly what spammers do, and unless you want to be banned from Google it's not a good idea to have more than 5 URLs redirecting to the same location.
  1. About.com
  2. Computing
  3. Web Design / HTML
  4. Web Server Management
  5. HTTP
  6. What's the difference between 301 redirects and 302 redirects

©2014 About.com. All rights reserved.