Thinkphp本地测试正常,在linux的nginx服务器上报404错误

本文共有1638个字,关键词:

问题:网站在本地windows系统apache服务器正常,上传到linux系统nginx服务器之后报404错误,thinkphp在linux访问页面打不开,报 404错误

解决:如果发生在本地测试正常,但是一旦部署到服务器环境后会发生只能访问首页的情况,很有可能是你的服务器或者空间不支持PATH_INFO所致。

方法:下面是thinkphp在nginx下nginx的配置方法

server {
    listen       80;
    server_name  www.zhtuu.com zhtuu.com;
    index index.html index.htm index.php;
    root /alidata/www/default;
    location / {
        try_files $uri @rewrite;
    }
    location @rewrite {
        set $static 0;
        if  ($uri ~ .(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css.map|min.map)$) {
            set $static 1;
        }
        if ($static = 0) {
            rewrite ^/(.*)$ /index.php?s=/$1;
        }
    }
    location ~ /Uploads/.*.php$ {
        deny all;
    }
    location ~ .php/ {
    if ($request_uri ~ ^(.+.php)(/.+?)($|?)) { }
        fastcgi_pass 127.0.0.1:9000;
        include fastcgi_params;
        fastcgi_param SCRIPT_NAME     $1;
        fastcgi_param PATH_INFO       $2;
        fastcgi_param SCRIPT_FILENAME $document_root$1;
    }
    location ~ .php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    location ~ /.ht {
        deny  all;
    }
    include /alidata/server/nginx/conf/rewrite/default.conf;
    access_log  /alidata/log/nginx/access/default.log;
}

参考:

http://my.oschina.net/zhuyajie/blog/523268
版权声明:本文为作者原创,如需转载须联系作者本人同意,未经作者本人同意不得擅自转载。
添加新评论
暂无评论