php 405 not allowed,405 Not Allowed 错误
生活随笔
收集整理的這篇文章主要介紹了
php 405 not allowed,405 Not Allowed 错误
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Apache、IIS、Nginx等大多數web服務器,都不允許靜態文件響應POST請求,否則會返回“HTTP/1.1 405 Method not allowed”錯誤。
用Linux下的curl命令發送POST請求給Apache服務器上的HTML靜態頁所得結果為:
# curl -d 1=1 http://www.sohu.com/index.html
405 Method Not AllowedMethod Not Allowed
The requested method POST is not allowed for the URL /index.html.
Apache/1.3.37 Server at www.sohu.com Port 80
用Linux下的curl命令發送POST請求給Nginx服務器上的HTML靜態頁所得結果為:
# curl -d 1=1 http://blog.s135.com/tech/index.htm
405 Not Allowed405 Not Allowed
nginx/0.5.35
在有些應用中,需要使靜態文件能夠響應POST請求。Nginx可以修改nginc.conf配置文件,改變“405錯誤”為“200 ok”,并配置location來解決,方法如下。
在server{}中增加如下配置:
error_page ? 405 =200 @405;
location @405
{
root ?web主目錄;
}
如果不需要調整服務器配置的話,也可以更改POST請求為GET請求。
window.open("URL","_blank");
總結
以上是生活随笔為你收集整理的php 405 not allowed,405 Not Allowed 错误的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 软件设计中的心跳机制
- 下一篇: 搜狗皮肤.php,搜狗皮肤制作