为了让 IIS 7.5 接受 PHP 5.4 快速 CGI 驱动的 REST API 的 PUT 和 DELETE,我必须禁用 WebDAV 模块。否则,WebDAV 模块将使用 PUT 或 DELETE 来干预 HTTP 请求。然而,要完成这项工作有点令人困惑,我可能错过了一些步骤或以其他顺序完成。
这些行被放置为<system.webServer>
- 元素在网络配置在应用程序根目录中。
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
希望这可以减少一些挫败感。似乎服务器的默认设置是接受任何未列出的 HTTP 动词 - 请参阅下面的设置Request filtering -> HTTP Verbs -> Edit feature Settings
。人们可以考虑明确添加允许的动词。允许的动词可以在附加此片段后指定,也可以作为<system.webServer>
.
<security>
<requestFiltering>
<verbs allowUnlisted="false">
<add verb="GET" allowed="true" />
<add verb="POST" allowed="true" />
<add verb="DELETE" allowed="true" />
<add verb="PUT" allowed="true" />
</verbs>
</requestFiltering>
</security>
在客户端计算机上,可以从此处卸载 WebDAV 模块:
Control Panel -> Uninstall Program -> Turn Windows features on or off -> IIS -> World Wide Web Services -> Common HTTP feautre -> WebDAV Publishing
让它发挥作用的最后一个措施是编辑applicationhost.config
在发现C:\Windows\System32\inetsrv\config
。之内<system.webServer> -> <handlers>
你会看到一个 php 条目,其中包含verb="GET,HEAD,POST
- 修改它以添加您需要的动词,例如:
<add name="PHP54_via_FastCGI" path="*.php" verb="GET,HEAD,PUT,DELETE,POST"/>
|
|
|
append verbs here ----------------------------------------------|