如何让 IIS6 识别 pathinfo 路由而不是返回“404 Unscribed”错误?
我正在使用 PHP 开发 RESTful Web 应用程序。我得到的是:
- 在测试服务器上,Windows 7 / Apache 2.2 / PHP 5.2.9 (mod_php)
- 在生产服务器上,Windows Server 2003 / IIS6 / PHP 5.2.4 (php5isapi.dll)
虽然测试环境没有问题,但生产服务器无法发送任何带有路径信息的 RESTful 请求(即像这样的页面) /mypath/app.php/controller/id
,其中处理脚本是 /mypath/app.php
),并给出一个漂亮的空白页面,其中包含以下消息:
No input file specified.
Using firebug,我可以看到响应标头是:
HTTP/1.1 404 Undescribed
Proxy-Connection: close
Connection: close
Via: 1.1 XXXXX
Date: Thu, 23 Jun 2011 14:51:18 GMT
Content-Type: text/html
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET, PHP/5.2.4
其中 XXXXX
是代理的名称。
我用谷歌搜索了一下,似乎无论是SO还是网络的其他部分都无法为这个问题提供实际的解决方案。有什么线索吗?
由于生产服务器需要跟上,因此不能重新安装 PHP 和/或 IIS。我能做的就是修改IIS/PHP配置,然后重新启动IIS。
预先感谢,
保罗
I am developing a RESTful web application in PHP. What I have got is:
- on the test server, Windows 7 / Apache 2.2 / PHP 5.2.9 (mod_php)
- on the production server, Windows Server 2003 / IIS6 / PHP 5.2.4 (php5isapi.dll)
While the test environment has got no problem, the production server fails to send any RESTful request with pathinfo (i.e., pages like e.g. /mypath/app.php/controller/id
, where the handling script is /mypath/app.php
) and gives a nice blank page with the message:
No input file specified.
Using firebug, I can see the response headers are:
HTTP/1.1 404 Undescribed
Proxy-Connection: close
Connection: close
Via: 1.1 XXXXX
Date: Thu, 23 Jun 2011 14:51:18 GMT
Content-Type: text/html
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET, PHP/5.2.4
Where XXXXX
is the name of the proxy.
I googled around and it seems like neither SO nor the rest of the web can give practical solutions to this problem. Any clue?
Since the production server needs to keep up, reinstalling PHP and/or IIS is not an option. What I can do is modify IIS/PHP configuration, and restart IIS.
Thanks in advance,
Paolo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
@hakre 发布了一个很好的答案,但解决这个问题的是另一件事,我简短地报告一下,以节省其他人几个小时的痛苦...
解决了这个问题
doc_root=...
行;services.msc
,重新启动“万维网发布服务”;现在,所有页面都可以正确报告
PATH_INFO
。不管怎样,谢谢你的回答!
如果有人关心的话,此页面照亮了我。
@hakre posted a good answer, but it was another thing that solved this issue, which I report briefly to save hours of pain to others...
I got rid of the problem by:
php.ini
on the production server, commenting out thedoc_root=...
line;services.msc
on the production server, restarted the "World Wide Web Publishing Service";now, all pages work just fine reporting
PATH_INFO
correctly.Thanks for the answers anyway!
If anyone cares, this page illuminated me.
取消选中验证文件存在复选框。
这是 Internet 信息服务管理器 中的一个选项,您可以在网站 属性 主目录
.php 配置中找到该选项代码> 应用程序映射。
编辑相关网站的映射并禁用文件存在检查。然后 pathinfo 应该按预期工作。
更多信息
Un-check the Verify that file exists check-box.
That's an option in the Internet Information Services Manager you can find in the Web Sites Properties Home Directory Configuration for the
.php
Application Mapping.Edit the mapping for the website in question and disable the file existance check. Then pathinfo should work as expected.
More Info
尝试使用 ISAPI_REWRITE 重写支持(http://www.isapirewrite.com/)
try rewrite support using ISAPI_REWRITE(http://www.isapirewrite.com/)