What are 307 and 308 redirects, and when should you use them?
guide // , 5 min read, by Darthwares
HTTP 307 and 308 status codes redirect request URLs while preserving the original HTTP method and body. You should use a 307 redirect for temporary resource moves and a 308 redirect for permanent resource moves whenever non-GET requests must retain their request method and payload. URL redirection, as documented by MDN Web Docs, is a technique to give more than one address to a web page, form, or application. When a browser receives a redirect response, it immediately loads the new URL specified in the Location header.
On this page // 5 sections
The short version
- HTTP 307 indicates a temporary redirection while preserving the original request method and body.
- HTTP 308 indicates a permanent redirection while preserving the original request method and body.
- Status codes 307 and 308 prohibit clients from changing POST requests into GET requests during redirection.
- Search engines receiving a 307 or 302 response will not attribute links to the new URL, whereas search engines receiving a 301 response will attribute links to the redirected resource and pass SEO ranking.
What is the difference between 307 and 308 redirects?
An HTTP 307 Temporary Redirect indicates that a requested resource has temporarily moved to the URL given in the Location header. MDN Web Docs documents that when a server issues a 307 response code, the method and body of the original request are reused to perform the redirected request. Browsers that receive a redirect response immediately load the new URL provided in the Location header.
An HTTP 308 Permanent Redirect indicates that a requested resource has permanently moved to the URL given in the Location header. A browser receiving this status code automatically requests the resource at the URL in the Location header, redirecting the user to the new page. In the redirected request, the client does not modify the request method or body.
The IETF specifies that the 308 status code indicates that the target resource has been assigned a new permanent URI and future references to this resource ought to use one of the enclosed URIs. The server should generate a Location header field containing a preferred URI reference for the new permanent URI. An HTTP 308 response is cacheable by default unless otherwise indicated by the method definition or explicit cache controls.
How do 307 and 308 differ from older 301 and 302 redirects?
The primary distinction between newer status codes and older 301 or 302 response codes involves how clients handle request methods. An HTTP 301 Moved Permanently status code indicates that the requested resource has permanently moved to the URL in the Location header. A 301 response requires the request method and body to remain unchanged, but older clients incorrectly handle this by using the GET method instead. Under the Fetch Standard, when a user agent receives a 301 in response to a POST request, it uses the GET method in the subsequent redirection request.
MDN Web Docs notes that 308 was created to remove the ambiguity of the behavior when using non-GET methods. While 308 is similar to 301, it does not allow changing the request method from POST to GET, and altering the method after a 308 response is prohibited. To avoid user agents modifying the request on permanent relocations, server configurations should use 308 Permanent Redirect instead of 301.
MDN Web Docs explains that 307 differs from 302 because 307 specifies that the client will not change the request method and body when making the redirected request. Altering the method after a 307 response is prohibited, whereas an HTTP 302 Found response indicates a temporary move but allows user agents to modify the request method. In cases where you want any request method to be changed to GET, HTTP documentation specifies using the 303 See Other status code.
How do search engines handle HTTP redirects?
Search engines process temporary and permanent redirects differently regarding link attribution and SEO value. MDN Web Docs documents that search engines receiving an HTTP 307 Temporary Redirect or an HTTP 302 Found response will not attribute links to the original URL to the new resource, meaning no SEO value is transferred to the new URL. Search engine robots and other crawlers do not memorize the new temporary URL.
For permanent redirects, search engine behavior is documented for the 301 status code. When search engines receive an HTTP 301 Moved Permanently response, they attribute links to the original URL to the redirected resource, passing the SEO ranking to the new URL.
How do you test and troubleshoot HTTP redirects?
URL redirection, also known as URL forwarding, is a technique to give more than one URL address to a page, a form, a whole website, or a web application. When browsers receive a redirect, they immediately load the new URL provided in the Location header. However, when forms or applications send POST requests, returning a 301 or 302 status code can cause user agents to alter the method to GET and drop request data. Using 307 Temporary Redirect or 308 Permanent Redirect prevents user agents from modifying the request, reusing the original method and body for the destination URL.
To diagnose whether redirects preserve request methods correctly, you can perform a step-by-step test on your server responses. Following this procedure verifies that response headers and client request payloads function as expected during URL forwarding.
- 01Send a POST request with a payload to the original URL.
- 02Inspect the HTTP response status code and check that a Location header containing the target URL is returned.
- 03Verify that the client makes the subsequent request to the new URL without modifying the POST method or altering the request body.
| Symptom | Possible Cause | Recommended Action |
|---|---|---|
| Form POST request changes to GET after redirection | Server returned a 301 or 302 response code | Use 308 Permanent Redirect or 307 Temporary Redirect |
| Search engines do not transfer link equity to the new page | Server returned a temporary 307 or 302 response code | Use 301 Moved Permanently to transfer SEO ranking |
| Client drops request body on temporary redirection | Server returned 302 Found allowing method modification | Use 307 Temporary Redirect to keep method and body unchanged |
Common questions
Why was the 308 Permanent Redirect status code created?
The 308 status code was created to remove the ambiguity of client behavior when using non-GET methods, prohibiting clients from altering the method or body.
Does a 307 Temporary Redirect transfer link equity?
No. Search engines receiving a 307 response will not attribute links to the original URL to the new resource, meaning no SEO value is transferred.
Is an HTTP 308 response cacheable?
Yes. An HTTP 308 response is cacheable by default unless indicated otherwise by explicit cache controls or the method definition.
Which status code should be used to change a request method to GET?
In cases where you want any request method to be changed to GET, MDN Web Docs specifies using the 303 See Other status code.
Primary sources and further reading
This article was researched and written by an AI model and published automatically. It was written from sentences that were checked to appear on the pages below, but a person has not reviewed the text. If something is wrong, tell us at chibivikramathithan@darthwares.com and we will correct it.