|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们!Apache、IIS、nginx等尽年夜多半web办事器,都不同意静态文件呼应POST哀求,不然会前往“HTTP/1.1405Methodnotallowed”毛病。
例1:用linux下的curl下令发送POST哀求给Apache办事器上的HTML静态页
- [root@localhost~]#curl-d11=1http://www.92csz.com/index.html<!DOCTYPEHTMLPUBLIC"-//IETF//DTDHTML2.0//EN"><HTML><HEAD><TITLE>405MethodNotAllowed</TITLE></HEAD><BODY><H1>MethodNotAllowed</H1>TherequestedmethodPOSTisnotallowedfortheURL/index.html.<P><HR><ADDRESS>Apache/1.3.37Serveratwww.92csz.comPort80</ADDRESS></BODY></HTML>
复制代码
例2:用linux下的curl下令发送POST哀求给nginx办事器上的HTML静态页
- [root@localhost~]#curl-d11=1http://www.92csz.com/index.htm<html><head><title>405NotAllowed</title></head><bodybgcolor="white"><center><h1>405NotAllowed</h1></center><hr><center>nginx/1.2.0</center></body></html>
复制代码
但在有些使用中,必要使静态文件可以呼应POST哀求。
关于Nginx,能够修正nginc.conf设置文件,改动“405毛病”为“200ok”,并设置location来办理,***以下:
- server{listen80;server_namewww.92csz.com;indexindex.htmlindex.htmindex.php;root/opt/htdocs;if(-d$request_filename){rewrite^/(.*)([^/])$http://$host/$1$2/permanent;}error_page405=200@405;location@405{root/opt/htdocs;}location~.*.php?${includeconf/fcgi.conf;fastcgi_pass127.0.0.1:10080;fastcgi_indexindex.php;}}
复制代码
固然也能够修正nginx源代码来办理
修正源代码,从头编译装置nginx
编纂nginx源代码
- [root@localhost~]#vimsrc/http/modules/ngx_http_static_module.c
复制代码
修正:找到上面一段正文失落
- /*if(r->method&NGX_HTTP_POST){returnNGX_HTTP_NOT_ALLOWED;}*/
复制代码
然后依照本来的编译参数,从头编译装置nginx,便可
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们! |
|