HTTP 303 See Other
The HTTP See Other status code is used when performing redirects.
Edited: 2020-01-04 22:38
The HTTP 303 See Other status code tells the browser that the response for the request can be found at a different location, wheres the new location should be provided in the location header.
Do not use this for redirects. If a page is moved, you should instead use the 301 response code.
Below is an example of how the 303 See Other redirect would look:
HTTP/1.1 303 See Other
Location: http://beamtic.com/
To deliver a 303 response with PHP, we can write a simple one-liner using the header function:
header("Location: https://example.com/",TRUE,303);
More ways to send a 303 response code
A more readable way of doing it would be by using http_response_code, this way we will not have to memorize the order of the parameters in the header function:
http_response_code(303);
header('Location: https://example.com/');
To instead send the headers raw, you would need to both make sure you use the right protocol, and be very careful not to misspell the headers:
header(set_protocol() . ' 303 See Other');
header('Location: https://example.com/');
function set_protocol() {
$supported_protocols = array(
'HTTP/2.0' => true,
'HTTP/1.1' => true,
'HTTP/1.0' => true,
);
$protocol = $_SERVER["SERVER_PROTOCOL"];
if (!isset($supported_protocols["$protocol"])) {
$protocol = 'HTTP/1.0';
}
return $protocol;
}
Tell us what you think: