我在开发我的个人网站www.88zhy.com的时候,发现在fcgi模式下header('HTTP/1.1 200 OK')不成功,使用非fcgi是可以成功的,这个是为什么呢?我想问一下在fcgi模式下怎样才能把head的状态修改为'HTTP/1.1 200 OK'呢?

解决方案 »

  1.   

    这个好像是PHP的一个bug,改用header("Status: 200");试试看
    或者升级PHP版本到最新的。
      

  2.   


    function sendHeader($num,$rtarr=NULL){
    $sapi = php_sapi_name();
    $header_a = array(
    '200' => 'OK',
    '206' => 'Partial Content',
    '304' => 'Not Modified',
    '404' => '404 Not Found',
    '416' => 'Requested Range Not Satisfiable',
    );
    if ($header_a[$num]){
    if ($sapi=='cgi' || $sapi=='cgi-fcgi') {
    $headermsg = "Status: $num ".$header_a[$num];
    } else {
    $headermsg = "HTTP/1.1: $num ".$header_a[$num];
    }
    if (empty($rtarr)){
    ob_end_clean();
    header($headermsg);exit;
    } else {
    return $headermsg;
    }
    }
    return '';
    }