📚 Quick Definition

The target resource resides temporarily under a different URI. Unlike 302, this status code guarantees that the request method and body will not be changed when the redirect is followed. A POST request will remain a POST request after following a 307 redirect, preserving the request body intact.

When It Occurs

A 307 Temporary Redirect is returned when the server needs to temporarily redirect the client to a different URI but requires that the client resend the exact same request (same method and body) to the new location. This is critical for POST, PUT, and DELETE requests where changing the method to GET would lose the request data.

🛠 Common Use Cases

  • POST form redirect where the method must stay POST
  • API endpoint temporarily moved while preserving request method
  • HTTPS enforcement for POST requests (HTTP POST to HTTPS POST)
  • Temporary URL change while preserving the request body
  • Payment processing redirects where POST data must be preserved

Best Practices

  • Use 307 when the request method must not change (POST stays POST, PUT stays PUT)
  • Always include the Location header with the temporary destination URI
  • Prefer 307 over 302 when method preservation matters
  • Search engines treat 307 similarly to 302 - the original URL stays indexed
  • 307 is temporary by nature - do not use for permanent changes (use 308 instead)

📡 HTTP Example

Request
POST /api/submit HTTP/1.1
Host: api.example.com
Content-Type: application/json

{
  "order_id": "ORD-789",
  "amount": 49.99
}
Response
HTTP/1.1 307 Temporary Redirect
Location: https://api.example.com/api/v2/submit

(client resends the same POST request with body to the new URL)

Frequently Asked Questions

Why use 307 instead of 302? +
The key reason to use 307 instead of 302 is method preservation. A 302 redirect may change a POST request to a GET request when following the redirect, which can cause data loss. A 307 guarantees the request method (POST, PUT, DELETE, etc.) and the request body will not change. Use 307 when the HTTP method matters, especially for form submissions and API endpoints.
What's the difference between 307 and 308? +
Both 307 and 308 preserve the HTTP method during a redirect. The difference is permanence: 307 is a temporary redirect (the original URL should still be used for future requests), while 308 is a permanent redirect (search engines and clients should update to the new URL). Think of it as: 307 is to 302 as 308 is to 301, but with guaranteed method preservation.
Do all browsers support 307? +
Yes, all modern browsers support the 307 Temporary Redirect status code. It has been supported since HTTP/1.1 and works in Chrome, Firefox, Safari, Edge, and all other current browsers. It is also well-supported by HTTP client libraries in all major programming languages like Python, JavaScript, Java, Go, and Ruby.