What is the difference between 301 and 302 redirection?


I would like to know the difference between these two types of redirection code: 301 and 302.

I noticed that they are called in the Google Webmaster Tools of Permanent redirect and Temporary redirect , respectively 301 and 302 .


  • But what's the difference? Is it so important to redirect using one or the other?

  • For example, in a redirect when the user logs in, should I use 301 or 302 ?

  • What would this "permanent" be? I did not quite understand. It seemed to be related to a url that will now always be redirected to another.

asked by anonymous 17.01.2017 / 20:10

2 answers


When the desired page is not in the expected place you can use 301 (for a permanent change) and 302 (for a temporary change).

Login redirects or page navigation fruit are something else, there's a interesting SOen post . Basically if you try to access an internal page without logging in, you should give 4xx.

At HTTP status specification says (free translation):

301 - permanent change, links and future access should use the new url.


The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs.

302 - found but temporarily available in another url, the client should continue to use the original url to access this content / page.


The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the SHOULD client continues to use the Request-URI for future requests.

17.01.2017 / 20:22

Permanent means that the old address "no longer exists" and this new is the "official". Temporary means that at some point the old address will be restored.

Think of a "In Maintenance" style page, the redirection to it is of the temporary type, because one hour the maintenance will end.

Let's just say that the company has changed its name, and the site redirects to a new domain with the new company name, the redirection is permanent, the old domain may even cease to exist at some point.

The application is very flexible, just the examples, the idea is to inform the browser (and search sites like Google) how to analyze the redirect.

In many cases, really, whatever.

17.01.2017 / 20:22