Description
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?
header('Referrer-Policy: unsafe-url');
header('Location: ' . $result['shortenedUrl']);
exit;
Resulted in this output:
HTTP response was 200 and the web page was not redirected.
But I expected this output instead:
HTTP response code should be 302 similar to other links.
PHP Version
PHP 8.2.28 (cli) (built: Apr 3 2025 13:03:28) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.28, Copyright (c) Zend Technologies
with the ionCube PHP Loader v14.4.0, Copyright (c) 2002-2025, by ionCube Ltd.
with Zend OPcache v8.2.28, Copyright (c), by Zend Technologies
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