IIS 7.5 enable DELETE/PUT Verbs with URL rewrite

1

I am trying to use the SLIM framework (PHP, REST) on a IIS 7.5. The problem i have is that i need to be able to use REST URL´s AND enable PUT,DELETE http verbs.

I have solved the REST URL problem with the help of SLIM on github (se web.config below). But i can´t solve the problem on activating the use of the verbs when i use URL rewrite.

Here is the error i receive: HTTP Error 405.0 - Method not allowed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.

Module StaticFileModule

Notification ExecuteRequestHandler

Handler StaticFile

Error Code 0x80070001

This is my web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
        <remove name="WebDAVModule"/>
    </modules>
        <rewrite>
            <rules>
                <rule name="slim" patternSyntax="Wildcard">
                    <match url="*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
iis-7.5
httpverbs
asked on Server Fault Apr 10, 2015 by Juw

1 Answer

1

Go to your "Handler Mappings" select the "*.php" handler in use. Then click "Edit", click "Request Restrictions", select the "Verbs" tab and choose "All verbs" or set the needed ones as a comma separated list (in your case "GET, POST, PUT, DELETE").

Edit: You may also check the checkbox "Invoke handler only if request is mapped to:" in the "Mapping" tab (left to the "Verbs" tab) and select "File or folder" This way you can call the base URI in a better way to get your root resource for example.

answered on Server Fault Dec 3, 2015 by user325399 • edited Dec 3, 2015 by user325399

User contributions licensed under CC BY-SA 3.0