Laravel 5.5 错误 405(不允许方法)XHR PUT METHOD 现在在 Azure 服务器上工作
Posted
技术标签:
【中文标题】Laravel 5.5 错误 405(不允许方法)XHR PUT METHOD 现在在 Azure 服务器上工作【英文标题】:Laravel 5.5 Error 405 (Method Not Allowed) XHR PUT METHOD now working on Azure Server 【发布时间】:2022-02-09 19:46:07 【问题描述】:我已经在安装了 php 7 的 Azure Web 服务器上安装了 Laravel 5.5。 除 XHR PUT METHOD 外,其他请求方法运行良好。它在控制台上返回错误消息:405 (Method Not Allowed) 和 XHR 网络预览:您正在查找的页面无法显示,因为正在使用无效的方法(HTTP 动词) .
我已经在 web.config
文件上允许了 PUT 方法
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="true"/>
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<clientCache httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" cacheControlMode="UseExpires" />
</staticContent>
<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains"/>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="X-Requested-With,Content-Type" />
<add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS,DELETE,PUT,PATCH" />
</customHeaders>
</httpProtocol>
<rewrite>
<rules>
<rule name="Laravel5" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="REQUEST_FILENAME" matchType="IsDirectory" negate="true" />
<add input="REQUEST_FILENAME" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<requestLimits maxQueryString="10000" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
请帮助我。 谢谢
【问题讨论】:
见:***.com/a/25171782/2544756 谢谢@rockhopper72,我已经按照答案将PHP版本更改为7.1,它对我有用。 【参考方案1】:通过这个问题,我找到了答案。 ***.com/a/25171782/2544756 通过将此代码添加到 system.Webserver
<handlers>
<remove name="PHP71_via_FastCGI" />
<add name="PHP71_via_FastCGI" path="*.php" verb="GET,PUT,POST,DELETE,HEAD,OPTIONS,TRACE,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK" modules="FastCgiModule" scriptProcessor="D:\Program Files (x86)\PHP\v7.1\php-cgi.exe" resourceType="Either" requireAccess="Script" />
</handlers>
但我需要将 PHP 版本更改为 7.1 期待吧
【讨论】:
以上是关于Laravel 5.5 错误 405(不允许方法)XHR PUT METHOD 现在在 Azure 服务器上工作的主要内容,如果未能解决你的问题,请参考以下文章