广告合作
  • 今日头条

    今日头条

  • 百度一下

    百度一下,你就知道

  • 新浪网

    新浪网 - 提供新闻线索,重大新闻爆料

  • 搜狐

    搜狐

  • 豆瓣

    豆瓣

  • 百度贴吧

    百度贴吧——全球领先的中文社区

  • 首页 尚未审核订阅工具 订阅

    405错误的解决方法

    来源:网络收集  点击:  时间:2024-05-04
    【导读】:
    可能在现实生活中很多人都不会405错误的解决方法,遇到时又很麻烦,所以,下面小编就为大家带来一篇关于javaWeb中405错误的解决方法。工具/原料more405错误方法/步骤1/6分步阅读

    例1:用linux下的curl命令发送POST请求给Apache服务器上的HTML静态页

    . 代码如下:

    # curl -d 11=1 http://www.jb51.net/index.html !DOCTYPE HTML PUBLIC -//IETF//DTD HTML 2.0//EN HTML HEAD TITLE405 Method Not Allowed/TITLE /HEAD BODY H1Method Not Allowed/H1 The requested method POST is not allowed for the URL /index.html.P HR ADDRESSApache/1.3.37 Server at www.jb51.net Port 80/ADDRESS /BODY /HTML

    2/6

    例2:用linux下的curl命令发送POST请求给nginx服务器上的HTML静态页

    . 代码如下:

    # curl -d 11=1 http://www.jb51.net/index.htm html headtitle405 Not Allowed/title/head body bgcolor=white centerh1405 Not Allowed/h1/center hrcenternginx/1.2.0/center /body /html

    3/6

    但在有些应用中,需要使静态文件能够响应POST请求。对于Nginx,可以修改nginc.conf配置文件,改变“405错误”为“200 ok”,并配置location来解决,方法如下:

    . 代码如下:

    server { listen 80; server_name www.jb51.net; 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; } location ~ .*\.php?$ { include conf/fcgi.conf; fastcgi_pass 127.0.0.1:10080; fastcgi_index index.php; } }

    4/6

    当然也可以修改nginx源代码来解决修改源代码,重新编译安装nginx编辑nginx源代码

    . 代码如下:

    # vim src/http/modules/ngx_http_static_module.c

    5/6

    修改: 找到下面一段注释掉

    . 代码如下:

    /* if (r-method NGX_HTTP_POST) { return NGX_HTTP_NOT_ALLOWED; } */

    6/6

    最后按照原来的编译参数,重新编译安装nginx,即可。

    本文关键词:

    版权声明:

    1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。

    2、本站仅提供信息发布平台,不承担相关法律责任。

    3、若侵犯您的版权或隐私,请联系本站管理员删除。

    4、文章链接:http://www.1haoku.cn/art_668307.html

    相关资讯

    ©2019-2020 http://www.1haoku.cn/ 国ICP备20009186号05-05 01:20:29  耗时:0.023
    0.0234s