-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Header Location redirects to 200 instead of 302 #18806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Setting the |
Hi, Thank you for the response.
|
We need an executable, reproducible example, and configuration of web-servers/proxies. This code does not reproduce for me: header('Referrer-Policy: unsafe-url');
header('Location: https://www.google.com');
It's very likely this is an issue on your end. If you're using a proxy, try without it, or check whether it may discard your http status code. |
Hi, The website is on a hosting platform with direct connection and proxies are not being used. Test Server Link: https://preproduction.shortlinksfaucet.xyz/ If you click on any of the buttons, it gets redirected to a new location with I am unable to reproduce the issue now. Please note that the issue was related to specific website and not other links when this happened. So I thought it might be related to the response being received using the The issue happened for few hours for a particular shortlink website and was resolved automatically. I tried to replicate later using the blank values and invalid URLs but it still showed 302 response code. Thank you |
Adding to the above, the server is behind cloudflare. I have also raised a concern in cloudflare community. https://community.cloudflare.com/t/does-cloudflare-cache-http-status-codes/806059 Based on the following information from cloudflare cache status codes , Cloudflare caches certain HTTP response codes by default.
Thank you |
Based on the above and following statements from cloudflare community, the issue seems to be due to caching.
https://community.cloudflare.com/t/does-cloudflare-cache-http-status-codes/806059 Thank you |
Thanks for letting us know. Closing this accordingly. |
Uh oh!
There was an error while loading. Please reload this page.
Description
Hi,
The following code has been part of the system for several years. However, a recent issue prevented the browser from redirecting as expected.
Typically, the code performs a redirection to a new URL with an HTTP status code of 302. Unfortunately, for one specific website, the redirection failed, and instead of a 302 response, the server returned an HTTP 200 status code.
When the URL is pasted directly into the browser, the website works fine. However, the issue arises when the redirection is triggered through the code.
This issue has now been resolved, but we would like to understand the circumstances under which this behaviour occurs and how to replicate it.
Could this be related to the website’s response time? If so, why does the PHP backend need to account for this particular website and return an HTTP 200 status code instead of the expected 302?
Resulted in this output:
But I expected this output instead:
PHP Version
Operating System
Linux vda6400.is.cc 4.18.0-425.19.2.lve.el8.x86_64 #1 SMP Thu Apr 6 12:07:52 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: