What does HTTP / 1.1 302 mean?

In some article I read, I said that it means a jump (from one URI to another), but I found it to be β€œ302” even when there really were no jumps!

+108
Jun 10 '09 at 0:06
source share
11 answers

Redirecting 302 means that the page has been temporarily moved, and 301 means that it has been constantly moved.

301s are good for SEO value, while 302s aren’t because the 301s instruct customers to forget the value of the original URL, while 302 stores the value of the original and can thus potentially reduce the value by creating two. different URLs, each of which creates the same content (search engines consider them as different duplicates, and not one resource with two names).

+71
Jun 10 '09 at 0:10
source

This question was asked a long time ago when RFC 2616 was still hanging out. Some answers to this question are based on a document that is no longer relevant at present. To quote Mark Nottingham , who at the time of this writing was the co-chair of the IETF HTTP and QUIC working groups:

Do not use RFC2616 . Delete it from your hard drives, bookmarks and write down (or responsibly recycle) all printed copies.

The old RFC 2616 has been superseded by the following documents, which together define the HTTP / 1.1 protocol:

Therefore, I want to give an answer based on RFC 7231 , which is the current link to HTTP / 1.1 status codes.

Status Code 302

Response with 302 is a common way to perform URL redirects. Along with status code 302 response should contain a Location header with a different URI. Such a header will be parsed by the user agent and then redirected:


Redirection example


Web browsers may change from POST to GET in the following request. If this behavior is undesirable, you can use status code 307 (temporary redirection) instead.

Here's how status code 302 is defined in RFC 7231 :

6.4.3. 302 Found

Status code 302 (Found) indicates that the target resource is temporarily under a different URI. Since the redirection can be changed if necessary, the client should continue to use the valid request URI for future requests.

The server MUST generate a Location header field in the response containing a URI reference for another URI. The user agent MAY use the value of the Location field to automatically redirect. The server response payload typically contains a short hypertext note with a hyperlink to different URIs.

Note: For historical reasons, the user agent MAY change the request method from POST to GET for a subsequent request. If this behavior is not desired, status code 307 (temporary redirection) can be used instead.

According to Mozilla's MDN web docs , a typical use case for 302 is:

The webpage is temporarily unavailable for reasons that were not unforeseen. Thus, search engines do not update their links.

Other redirection status codes

RFC 7231 defines the following status codes for redirection:

  • 301 (constantly moved)
  • 302 (found)
  • 307 (Temporary redirection)

RFC 7238 is designed to define a different status code for redirection:

  • 308 (permanent redirect)

See this answer for more information.

+50
Aug 15 '17 at 10:38 on
source

A simple way to view HTTP 301 redirects against 302:

Suppose you have a bookmark " http://sample.com/sample ". You use a browser to go there.

A 302 redirecting to another URL at this point means that you must save your bookmark in " http://sample.com/sample ". This is because the destination URL may change in the future.

301 redirects to another URL will mean that your bookmark needs to change to point to a new URL, as this is a permanent redirect.

+24
Jun 10 '09 at 0:18
source

From RFC 2616 (Hypertext Transfer Protocol Specification) :

 10.3.3 302 Found

    The requested resource resides temporarily under a different URI.
    Since the redirection might be altered on occasion, the client SHOULD
    continue to use the Request-URI for future requests.  This response
    is only cacheable if indicated by a Cache-Control or Expires header
    field.

    The temporary URI SHOULD be given by the Location field in the
    response.  Unless the request method was HEAD, the entity of the
    response SHOULD contain a short hypertext note with a hyperlink to
    the new URI (s).

Source:

http://www.ietf.org/rfc/rfc2616.txt

+10
Jun 10 '09 at 0:19
source

From Wikipedia :

HTTP 302 response status code The most common method for redirecting was found. This is an example of manufacturing practice contrary to the standard.

+5
Jun 10 '09 at 0:08
source

According to the definitions of the status code, http 302 indicates a (temporary) redirect. "The requested resource is temporarily under a different URI"

+5
Jun 10 '09 at 0:11
source

302 is a response indicating a change in the location of a resource β€” Found.

The URL where the resource should be located should be in the header of the "Location" response.

The "jump" must be performed by the requesting client (enter a new request to the resource URL in the "Response Header Field" field).

+5
Jun 10 '09 at 0:14
source

In the SEO period, 301 and 302 are both good, it depends on the situation,

If only one version can be returned (i.e. another redirects to it), that's great! This behavior is useful because it reduces duplicate content. In the particular case of redirecting to final slash URLs, our search results will most likely show a version of the URL with a response code of 200 (most often an end slash) - regardless of whether the redirect was 301 or 302.

+5
Dec 03 '12 at 7:13
source

HTTP code 302 is for redirection, see http://en.wikipedia.org/wiki/HTTP_302 .

He reports that he is browsing the page to go to another place and load another page. Its use is very common.

+2
Jun 10 '09 at 0:10
source

According to RFC 1945 / Hypertext Transfer Protocol - HTTP / 1.0 :

  302 Moved Temporarily The requested resource resides temporarily under a different URL. Since the redirection may be altered on occasion, the client should continue to use the Request-URI for future requests. The URL must be given by the Location field in the response. Unless it was a HEAD request, the Entity-Body of the response should contain a short note with a hyperlink to the new URI(s). If the 302 status code is received in response to a request using the POST method, the user agent must not automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued. Note: When automatically redirecting a POST request after receiving a 302 status code, some existing user agents will erroneously change it into a GET request. 
+1
Jan 31 '17 at 17:44
source
  • Code 302 indicates a temporary redirect .
  • One of the most notable features that distinguish it from 301 redirects is that in the case of 302 redirects, SEO power is not transferred to the new URL.
  • This is because this redirect is intended to be used in cases where it is necessary to redirect content to a page that is not final. Thus, after eliminating the redirect, the original page will not lose its position in the Google search engine.

EXAMPLE: - Although we rarely need a 302 redirect, in some cases this option can be very useful. These are the most common cases:

  • When we understand that the page contains inappropriate content. While we are solving the problem, we can redirect the user to another page that may be of interest.
  • If an attack on our site requires the restoration of any of the pages, this redirect can help us minimize the incidence of disease.

Redirect 302 is a code that informs visitors to a specific URL that a page has been temporarily moved, and directs them directly to a new location.

  • In other words, redirect 302 is activated when Googlebots or other search engines request a specific page to load. At this point, thanks to this redirection, the server returns an automatic response with a new URL.

  • Thus, errors and troubles are excluded for both search engines and users, guaranteeing smooth navigation.

See this article for more details.

0
Sep 04 '19 at 6:22
source



All Articles