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');