PHP & 技术 18 Nov 2006 01:34 pm

php header 404

当使用cgi模式时使用

  1. header("Status: 404 Not Found");

mod_php使用

  1. header("HTTP/1.1 404 Not Found");

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

万全的方法

  1. function header_status($status)
  2. {
  3.  
  4.    // 'cgi', 'cgi-fcgi'
  5.    if (substr(php_sapi_name(), 0, 3) == 'cgi')
  6.        header('Status: '.$status, TRUE);
  7.    else
  8.        header($_SERVER['SERVER_PROTOCOL'].' '.$status);
  9. }
  10. header_status('404 Not Found');

Trackback This Post | Subscribe to the comments through RSS Feed

Leave a Reply