从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;