307 Temporary Redirect

HTTP response status code 307 Temporary Redirect is returned by the server to indicate that the requested resource has been temporarily moved to a new location and was introduced in the HTTP/1.1 specification.

Usage

This status indicates that the target resource is available at a different URL. The agent is expected to make a new HTTP request to the URL specified in the Location HTTP header and is not allowed to alter the HTTP request method. The 307 Temporary Redirect status code works the same way that the 302 Found status code does, except that 307 Temporary Redirect status code specifically guarantees that the HTTP method and message body will not be changed in the follow-up HTTP request.

Where it is desirable for the HTTP request method to change, using 303 See Other status code instead is the recommended alternative. An example of this is redirecting a POST HTTP request entered on a form, to loading another page using GET HTTP method, e.g. to show a confirmation message of successful submission of the form.

After submitting the original HTTP request and HTTP method to the new URL, it will be processed by the server. It is important to note that 307 Temporary Redirect status code is not persistent, and as such, future HTTP requests are expected to use the original URL to revalidate the temporary address change.

The HTTP response is by default not cached. To make the redirect [caching|cacheable], add a Cache-Control or Expires HTTP header.

The 307 Temporary Redirect status code can also be used as an internal redirect when an HSTS policy through the Strict-Transport-Security HTTP header and/or HSTS preload list is declared. For example, the HTTP client may use the status code for redirection from HTTP to a secure connection using HTTPS without making a connection to the server.

Note

Search engines may interpret an URI returning a 307 Temporary Redirect status code over a prolonged period of time as equal to the 301 Moved Permanently or 308 Permanent Redirect status codes and treat it as such.

Example

In the example, the client requests that a specific resource be retrieved from the server. In response, the server sends the 307 Temporary Redirect status code because the resource is available at an alternate specified location.

Request

GET /news.html HTTP/1.1
Host: www.example.re

Response

HTTP/1.1 307 Temporary Redirect
Location: http//www.example.re/breaking/news.html

Code references

.NET

HttpStatusCode.TemporaryRedirect

Rust

http::StatusCode::TEMPORARY_REDIRECT

Rails

:temporary_redirect

Go

http.StatusTemporaryRedirect

Symfony

Response::HTTP_TEMPORARY_REDIRECT

Python3.5+

http.HTTPStatus.TEMPORARY_REDIRECT

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_TEMPORARY_REDIRECT

Angular

@angular/common/http/HttpStatusCode.TemporaryRedirect

Takeaway

The 307 Temporary Redirect status code indicates that the resource is currently available at an alternate URL and the client needs to issue an identical HTTP request to retrieve it. Because it is temporary, existing links do not need to be modified to reflect the change.

See also

Last updated: August 2, 2023