2013-04-09 94 views
4

我正在使用Azure网站构建简单的PHP Web服务,并且无法使其支持PUT和DELETE http方法。假设这是必须进入web.config文件的东西 - 我已经尝试了一些来自interwebs的选项,但它们中的一些看起来没有正常工作。有任何想法吗?Azure网站PHP API - 405方法不允许使用PUT和DELETE

这里的web.config文件,因为它目前为:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
    <handlers> 
    </handlers> 
    <security> 
    </security> 
    <directoryBrowse enabled="false" /> 
    <caching> 
     <profiles> 
     <add extension=".php" policy="DontCache" kernelCachePolicy="DontCache" /> 
     <add extension=".html" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="14:00:00" /> 
     </profiles> 
    </caching> 
    <rewrite> 
     <rules> 
     <rule name="block favicon" stopProcessing="true"> 
      <match url="favicon\.ico" /> 
      <action type="CustomResponse" statusCode="404" subStatusCode="1" 
      statusReason="The requested file favicon.ico was not found" 
      statusDescription="The requested file favicon.ico was not found" /> 
     </rule> 
     <rule name="Cols Rule" stopProcessing="true"> 
      <match url="^(.*)$" ignoreCase="false" /> 
      <conditions> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> 
      <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" /> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" /> 
     </rule> 
     </rules> 
    </rewrite> 
    <defaultDocument> 
     <files> 
     <remove value="index.php" /> 
     <add value="index.php" /> 
     </files> 
    </defaultDocument> 
    </system.webServer> 
</configuration> 
+0

几天前我看到了类似的线程。在这种情况下,事实证明PUT动词被内部网络阻塞。你能检查一下,这是不是这种情况? – 2013-04-09 17:36:36

回答

3

我没有看到你有处理程序加入到你的web.config。我没有亲自测试过,但有人建议PUT和DELETE应该可以与Windows Azure网站一起使用,但是您需要通过web.config在Windows Azure网站上正确配置它们。

以下是简单的配置,你可以用它来设置它:

<configuration> 
<system.webServer> 
    <handlers> 
     <remove name="PHP53_via_FastCGI" /> 
     <add name="PHP53_via_FastCGI" path="*.php" 
       verb="GET, PUT, POST, HEAD, DELETE" 
       modules="FastCgiModule" 
       scriptProcessor="D:\Program Files (x86)\PHP\v5.3\php-cgi.exe" 
       resourceType="Either" requireAccess="Script" /> 
    </handlers> 
</system.webServer> 
</configuration> 
+0

<除去名称= “PHP54_via_FastCGI”/> <添加名称= “PHP54_via_FastCGI” 路径= “*。PHP” 动词= “GET,PUT,POST,DELETE,HEAD” 模块= “FastCgiModule” scriptProcessor = “D:\ Program Files(x86)\ PHP \ v5.4 \ php-cgi.exe” resourceType =“要么”requireAccess =“Script”/> 2013-04-10 11:25:44

+0

这篇文章做的很好,覆盖了Windows Azure网站上的配置http://blog.maartenballiauw.be/post/2012/07/09/Tweaking-Windows-Azure-Web-Sites.aspx – 2013-05-02 20:43:38

3

它没有与DELETE工作作为最后的选择,这里是修改PHP54在Azure上的代码。但是要感谢Avkash!

<handlers> 
    <remove name="PHP54_via_FastCGI" /> 
     <add name="PHP54_via_FastCGI" path="*.php" 
       verb="GET, PUT, POST, DELETE, HEAD" 
       modules="FastCgiModule" 
       scriptProcessor="D:\Program Files (x86)\PHP\v5.4\php-cgi.exe" 
       resourceType="Either" requireAccess="Script" /> 
    </handlers> 
+5

现在HEAD是最后一个选项,它停止工作。我在HEAD之后添加了一个逗号,现在它再次运行。奇怪的。 – 2014-03-31 20:12:14

+0

不错,谢谢..添加一个假人也适用。 – 2015-09-24 11:27:03