What Is a 307 Status Code?
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.
Since the redirection can change over time, the client ought to continue using the original effective request URI for future requests.
The server SHOULD generate a Location header field in the response containing a URI reference for the different URI. The user agent MAY use the Location field value for automatic redirection. The server’s response payload usually contains a short hypertext note with a hyperlink to the different URI(s).
Note: This status code is similar to 302 Found, except that it does not allow changing the request method from POST to GET. This specification defines no equivalent counterpart for 301 Moved Permanently (RFC7238, however, proposes defining the status code 308 Permanent Redirect for this purpose).
- Source: RFC7231 Section 6.4.7
307 CODE REFERENCES
Rails HTTP Status Symbol
Go HTTP Status Constant
Symfony HTTP Status Constant
Python2 HTTP Status Constant
Python3+ HTTP Status Constant
Python3.5+ HTTP Status Constant
HttpComponents Core org.apache.hc.core5.http.HttpStatus.SC_TEMPORARY_REDIRECT
3 best practices for using the 307 status code
Here are some best practices for implementing the 307 status code effectively:
- Use the 307 status code only for temporary redirects: If a resource has permanently moved to a new URL, use a 301 status code instead.
- Ensure the original resource remains accessible: When using the 307 status code, it’s crucial to ensure users can still access the original resource. This prevents errors and ensures any cached data remains intact.
- Use the correct HTTP method: When redirecting a resource, use the correct HTTP method. For example, if the original resource used a POST request, the redirected resource should also use a POST request.
Use our free redirect checker tool to ensure the redirect destination URL is correct and functional.
3 common 307 temporary redirect mistakes
Here are some common mistakes with the 307 status code:
- Misinterpreting the 307 status code as a permanent redirect: While the 307 status code indicates a resource has temporarily moved, some developers mistakenly interpret it as a permanent redirect. This can lead to errors and negatively impact user experience.
- Using the 307 status code for permanent redirects: When a resource has permanently moved, developers should use the 301 status code instead of the 307 status code. Failing to do so can create duplicate content and negatively impact search engine optimization (SEO).
- Using the 307 status code for resources that have moved permanently but still require the same URL: In some cases, a resource may have moved to a new location but still require the same URL. In this case, developers should use the 301 status code instead of the 307 status code.
How to troubleshoot a 307 status code
If you’re getting a 307 status code you weren’t expecting, here are some steps you can take:
- Check your website’s code: The first step is to check your website’s code to ensure there are no issues that could be causing the 307 status code. Look for any redirects that may be incorrectly configured or any other issues that may be causing the problem.
- Use the correct HTTP method: If you are using the wrong HTTP method, it can result in a 307 status code. Make sure you are using the correct method for the resource you are trying to access.
- Ensure the original resource remains accessible: If the original resource is not accessible, it can cause a 307 status code. Check to make sure the original resource is still available and that there are no issues preventing access to it.
- Use the 307 status code only for temporary redirects: Make sure you are only using the 307 status code for temporary redirects. If you use it for permanent redirects, it can cause issues with search engine optimization.
- Test and monitor your website: Once you have made any necessary changes, test and monitor your website to ensure that the issue has been resolved. You can use tools like Google Search Console or a website monitoring service to keep an eye on your website’s status and detect any issues.
Learn more about a 307 temporary direct with these FAQs:
Why is a 307 HTTP status code important?
The 307 status code plays a critical role in website performance.
By using the 307 status code, developers ensure users can access the original resource and that their cached data remains intact. This improves user experience by reducing the amount of time it takes to load a page and allowing users to continue where they left off in a session.
The 307 status code is also essential for search engine optimization. By using the 307 status code instead of the 302 status code, developers can avoid creating duplicate content, which can negatively impact a website’s SEO ranking.
What is the difference between a 307 status code and 302 status code?
Both the 307 and 302 status codes indicate a temporary redirect.
The 307 status code requires the client to use the same HTTP method in the redirected request as the original request, while the 302 status code does not. This means that if a client sends a POST request to a resource that returns a 307 status code, the client must resend the POST request to the redirected URL, while a 302 status code would allow the client to resend the request using any HTTP method.
What is the difference between a 307 status code and 308 status code?
Both the 307 and 308 status codes indicate a temporary redirect.
The 307 status code requires the client to use the same HTTP method in the redirected request as the original request, while the 308 status code does not only require that the client use the same HTTP method, but also requires that the request be retried using the same URI.
In other words, the 308 status code indicates that the original request should be repeated with the same HTTP method and URI to ensure that the redirected resource is accessed correctly.
- Learn about web development
- Learn about SEO
- Web development services from WebFX
- SEO services from WebFX
- MDN Web Docs