zoukankan      html  css  js  c++  java
  • Nginx 静态页面POST 请求提示405 Not Allowed

    从git上cp了一个开源的前端框架lay Ajax版本,用Nginx配置访问首页没问题

    nginx配置如下:

    server
        {
            listen 80;
            server_name adminhtml.com;
            index index.html index.htm index.php;
            root  /home/wwwroot/adminhtml;
        autoindex  on;
            include enable-php.conf;
            access_log  /home/wwwlogs/access.log;
        }

    但点击菜单(ajax实现),浏览器提示

    Nginx: 405 Not Allowed

    猜了下估计是ajax post的问题,搜索后果然

    nginx是不允许post访问静态资源

    ------------------------------

    解决办法

    将405状态指向200 ok

    配置Nginx如下:

    server
        {
            listen 80;
            server_name adminhtml.com;
            index index.html index.htm index.php;
            root  /home/wwwroot/adminhtml;
            location ~ .*.(htm|html|gif|jpg|jpeg|png|ico|css|js|txt|flv|doc)$ {  
            error_page 405 =200 $uri;  
            }
        autoindex  on;
            include enable-php.conf;
            access_log  /home/wwwlogs/access.log;
        }

    记得重启Nginx

     service nginx reload

    注意: 当允许访问目录时

    autoindex  on;

    要加编码,否则,如果目录或文件有中文就会显示乱码,so, 要加一行代码

    charset utf-8,gbk;
  • 相关阅读:
    flutter 布局
    常见错误
    xpath
    bzoj1485 [HNOI2009]有趣的数列 卡特兰数
    博弈 Nim问题 POJ2234
    bzoj 1014 [JSOI2008]火星人prefix
    codevs 1743 反转卡片 rope or splay
    bzoj 2326 矩阵乘法
    bzoj 1702 贪心,前缀和
    bzoj 1700 Problem Solving 解题 dp
  • 原文地址:https://www.cnblogs.com/dcb3688/p/4608050.html
Copyright © 2011-2022 走看看