Nginx 靜態頁面POST 請求提示405 Not Allowed

從git上cp了一個開源的前端框架lay Ajax版本,用Nginx配置訪問首頁沒問題php

nginx配置以下:css

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實現),瀏覽器提示html

Nginx: 405 Not Allowed前端

猜了下估計是ajax post的問題,搜索後果真nginx

nginx是不容許post訪問靜態資源git

------------------------------ajax

解決辦法瀏覽器

將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;
相關文章
相關標籤/搜索