Skip to main content
307

Temporary Redirect

Active
RFC 9110 §15.4.8Since 1999HTTPS enforcement, API redirects, load balancing

HTTP 307 Temporary Redirect indicates the resource resides temporarily at a different URI, and the request method MUST NOT be changed. Defined in RFC 9110 §15.4.8. Unlike 302, guarantees POST remains POST.

Description

The 307 Temporary Redirect status code indicates that 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.

This was introduced to address the ambiguity of 302, where many clients incorrectly changed POST to GET on redirect. 307 guarantees method preservation.

Examples

POST request to old endpoint
http
POST /api/v1/orders HTTP/1.1
Host: api.example.com
Content-Type: application/json

{"item": "widget"}
307 preserves POST method
http
HTTP/1.1 307 Temporary Redirect
Location: https://api.example.com/api/v2/orders

Edge Cases

  • The request method MUST be preserved — POST stays POST, PUT stays PUT.
  • The request body must also be re-sent to the new location.
  • Browsers may prompt the user before re-sending a POST to the new URL.

When You'll See This

  • HTTP to HTTPS redirect with HSTS
  • API version migration (temporary)
  • Load balancer routing to different backend

Implementation References

LanguageConstant
Gohttp.StatusTemporaryRedirect
Rusthttp::StatusCode::TEMPORARY_REDIRECT
Pythonhttp.HTTPStatus.TEMPORARY_REDIRECT
Node.jshttp.STATUS_CODES[307]
.NETHttpStatusCode.TemporaryRedirect
Java(no built-in constant, use 307 literal)

History

Introduced in HTTP/1.1 (RFC 2616, 1999) specifically to fix the 302 method-changing ambiguity. 302 was supposed to preserve the method but implementations didn't.

Related Status Codes

Related Headers

FAQ

What is the difference between 302 and 307?

307 guarantees the HTTP method is preserved (POST stays POST). 302 may change POST to GET in some implementations.

When should I use 307 vs 308?

307 is temporary (like 302 but method-safe). 308 is permanent (like 301 but method-safe). Use 307 for temporary redirects where you need method preservation.