小雨点点789 发表于 2016-12-27 06:42:25

Nginx HTTP Post Method: 405 Method not allowed

  

  Apache、IIS、Nginx等绝大多数web服务器,都不允许静态文件响应POST请求,否则会返回“HTTP/1.1 405
  Method not allowed”错误
  测试工具:可以使用 http://code.google.com/p/rest-client/ 或者 curl 命令
  如果一定要用post方式访问,对于Nginx,可以修改nginc.conf配置文件,改变“405错误”为“200 ok”,并配置location来解决,方法如下:








server
{
listen       80;
server_namelocalhost;
index index.html index.htm index.php;
root/opt/htdocs;
if (-d $request_filename)
{
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}
error_page   405 =200 @405;
location @405
{
root/opt/htdocs;
}
}
 
页: [1]
查看完整版本: Nginx HTTP Post Method: 405 Method not allowed