Header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found');
When creating a 404 page, the following data is often sent to the headers
HTTP/1.1 404 Not Found
Status: 404 Not Found
The first title is clear. But, what does 2 mean and is it necessary at all?
0
1 answers
It depends on how the server interacts with PHP. For FastCGI, you need to send Status:..., for other methods HTTP/1.1 ...:
$sapi_name = php_sapi_name();
if ($sapi_name == ‘cgi’ || $sapi_name == ‘cgi-fcgi’) {
header(‘Status: 404 Not Found’);
}
else {
header($_SERVER['SERVER_PROTOCOL'] . ‘ 404 Not Found’);
}
1
Author: MDJHD, 2014-01-29 21:37:25