To get PUT and DELETE to be accepted by IIS 7.5 for a PHP 5.4 fast-CGI driven REST API I had to disable the WebDAV-module. Otherwise the WebDAV module intervenes the HTTP requests using PUT or DELETE. To get this working was however a bit confusing and I might have missed some steps or done it in another order.
These lines are placed as children of the <system.webServer>
-element in web.config in the application root.
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
Hopes this might spare some frustration. It seems like the default setting for the server is to accept any HTTP verb not listed – see settings under Request filtering -> HTTP Verbs -> Edit feature Settings
. One may consider to explicitly add the VERBS that are to be allowed. The verbs allowed may be specified appending this snippet, also as a child of <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>
On a client machine one can uninstall the WebDAV module from here:
Control Panel -> Uninstall Program -> Turn Windows features on or off -> IIS -> World Wide Web Services -> Common HTTP feautre -> WebDAV Publishing
The last measure to get it working was by editing applicationhost.config
found in C:\Windows\System32\inetsrv\config
. Within <system.webServer> -> <handlers>
you will see a php entry that has just verb="GET,HEAD,POST
– amend it to add the verbs you require, e.g.:
<add name="PHP54_via_FastCGI" path="*.php" verb="GET,HEAD,PUT,DELETE,POST"/>
|
|
|
append verbs here ----------------------------------------------|