Middle
What is the difference between 306 and 307 Redirects?
sobes.tech AI
Answer from AI
306 – this is not a standard HTTP status; it was reserved but not used and is not recommended for use. 307 (Temporary Redirect) indicates that the resource has been temporarily moved, and the client should repeat the request to the new URI while preserving the request method (GET remains GET, POST remains POST, etc.).
Comparison of 307 and 302 (Found), which is often used for temporary redirects, but historically clients could change the method from POST to GET during redirection:
| Status | Name | Description | Change of request method |
|---|---|---|---|
| 302 | Found | The resource is temporarily available at a different URI. Clients may change the method. | Possible |
| 307 | Temporary Redirect | The resource is temporarily available at a different URI. Clients should not change the method. | No change |
Example of using 307 in PHP:
<?php
// Temporary redirect
header("HTTP/1.1 307 Temporary Redirect");
header("Location: /new_temporary_location");
exit();