Takeaways
- The target resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client ought to continue to use the effective request URI for future requests.
- The server should generate a
Location
header field in the response containing a URI reference for the different URI. - The user agent may use the
Location
field value for automatic redirection. - The server's response payload usually contains a short hypertext note with a hyperlink to the different URI(s).
NoteFor historical reasons, a user agent MAY change the request method from
POST
toGET
for the subsequent request. If this behaviour is undesired, the307
status code can be used instead.
Information
The 302 Found
redirect status response code indicates that the resource requested has been temporarily moved to the URL given by the Location
header. A browser redirects to this page but search engines don't update their links to the resource (in 'SEO-speak', it is said that the 'link-juice' is not sent to the new URL).
Even if the specification requires the method (and the body) not to be altered when the redirection is performed, not all user-agents conform here - you can still find this type of bugged software out there. It is therefore recommended to set the 302
code only as a response for GET
or HEAD
methods and to use 307 Temporary Redirect
instead, as the method change is explicitly prohibited in that case.
In the cases where you want the method used to be changed to GET
, use 303 See Other
instead. This is useful when you want to give a response to a PUT
method that is not the uploaded resource but a confirmation message such as: 'you successfully uploaded XYZ'.