Temporary Redirect
ActiveHTTP 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 /api/v1/orders HTTP/1.1
Host: api.example.com
Content-Type: application/json
{"item": "widget"}HTTP/1.1 307 Temporary Redirect
Location: https://api.example.com/api/v2/ordersEdge 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
| Language | Constant |
|---|---|
| Go | http.StatusTemporaryRedirect |
| Rust | http::StatusCode::TEMPORARY_REDIRECT |
| Python | http.HTTPStatus.TEMPORARY_REDIRECT |
| Node.js | http.STATUS_CODES[307] |
| .NET | HttpStatusCode.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.