Skip to content


php header 404

当使用cgi模式时使用

header(“Status: 404 Not Found”);

mod_php使用

header(“HTTP/1.1 404 Not Found”);

其中Not Found无意义,仅供显示。

万全的方法

function header_status($status)
{

// ‘cgi’, ‘cgi-fcgi’
if (substr(php_sapi_name(), 0, 3) == ‘cgi’)
header(‘Status: ‘.$status, TRUE);
else
header($_SERVER[‘SERVER_PROTOCOL’].’ ‘.$status);
}
header_status(‘404 Not Found’);

Posted in PHP, 技术.


No Responses (yet)

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.