仍然需要为FCGI使用“状态:404未找到”? [英] Still necessary to use 'Status: 404 Not Found' for FCGI?

查看:171
本文介绍了仍然需要为FCGI使用“状态:404未找到”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,当从PHP发送http状态标头时,会发送HTTP标头,如下所示:

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

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

然而, PHP手册说,对于FCGI主机,需要发送一个状态标头,然后由FCGI模块转换为HTTP标头:

However, the PHP manual says that for FCGI hosts, one would need to send a "Status" header that is then converted into a HTTP header by the FCGI module:

header("Status: 404 Not Found");

我在Windows 7机器上使用mod_fcgi运行apache 2.2,并使用 header(HTTP / 1.0 404 Not Found); 似乎工作正常。

I am running apache 2.2 with PHP using mod_fcgi on a Windows 7 machine and sending the header using just header("HTTP/1.0 404 Not Found"); seems to work fine.

这最近有变化吗?我还需要为FCGI主机发送状态标头吗?任何人都可以为其他平台(solaris,linux)和其他网络服务器(nginx,lighttp)确认这个吗?

Is this something that has changed recently? Do I still need to send a Status header for FCGI hosts? Could anyone also confirm this for other platforms (solaris, linux) and other webservers (nginx, lighttp)?

推荐答案

我不知道t相信你需要使用'Status'样式标题,除非你启用了cgi.rfc2616_headers选项。

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

该选项的描述是 http://php.net/manual/en/ini.core.php


告诉PHP在发送HTTP响应
代码时使用哪种类型的标头。如果设置为0,PHP会发送一个由$支持的Status:标头b $ b Apache和其他Web服务器。当此选项设置为1时,PHP将
发送»RFC 2616兼容标头。除非你知道
你正在做什么,否则将它设置为0。

"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."

基本上,您正在向PHP发送HTTP样式标头,然后PHP会在必要时将这些标头转换为状态样式标头。多年来似乎存在各种错误,其中这些错误要么被错误地转换,要么一次发送多个状态标题 - 但是现在所有这些错误似乎都已修复。所以我认为你只是设置HTTP样式标题并让PHP转换它们是安全的。

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.

我还测试并发送标题(HTTP / 1.0 404 Not Found );使用FastCGI

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

这篇关于仍然需要为FCGI使用“状态:404未找到”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆