Still necessary to use 'Status: 404 Not Found' for FCGI?

前端 未结 1 1976
情话喂你
情话喂你 2021-01-13 13:09

Usually, when sending a http status header from PHP, one would send the HTTP header like this:

header("HTTP/1.0 404 Not Found");

Ho

相关标签:
1条回答
  • 2021-01-13 14:06

    I don't believe you need to use the 'Status' style header unless you have the option cgi.rfc2616_headers enabled.

    The description of that option is http://php.net/manual/en/ini.core.php

    "Tells PHP what type of headers to use when sending HTTP response code. If it's set 0, PHP sends a Status: header that is supported by Apache and other web servers. When this option is set to 1, PHP will send » RFC 2616 compliant headers. Leave it set to 0 unless you know what you're doing."

    Basically you're sending HTTP style headers to PHP and then PHP converts these to the 'Status' style headers where necessary. It seems there were various bugs over the years where either these were either converted incorrectly or multiple 'Status' headers were sent at once - however all those bugs seem to be fixed now. So I think you're safe just setting the HTTP style headers and letting PHP convert them.

    Also I just tested and sending the header("HTTP/1.0 404 Not Found"); works fine on my dev environment using FastCGI

    0 讨论(0)
提交回复
热议问题