Takeaways
- The
307 Temporary Redirect
status response code indicates that the resource requested has been temporarily moved to the URL given by theLocation
headers. - The method and the body of the original request are reused to perform the redirected request.
- In the cases where you want the method used to be changed to
GET
, use303 See Other
instead. This is useful when you want to give an answer to aPUT
method that is not the uploaded resources, but a confirmation message (like "You successfully uploaded XYZ"). - The only difference between
307
and302
is that307
guarantees that the method and the body will not be changed when the redirected request is made. - With
302
, some old clients were incorrectly changing the method toGET
: the behaviour with non-GET
methods and302
is then unpredictable on the Web, whereas the behaviour with307
is predictable. ForGET
requests, their behaviour is identical.
Information
The target resource resides temporarily under a different URI and the user agent must not change the request method if it performs an automatic redirection to that URI.
Since the redirection can change over time, the client ought to continue using the original 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).