nginx thinkphp 总是返回首页

发布时间: 2019-09-17 15:11:07 作者: 大象笔记

例如,访问

http://localhost/solution.html

总是指向网站首页,但是修改成

http://localhost/?s=solution

这个链接格式之后,就是正常的。

说明这个符合 thinkphp 的 redirect url 模式。

可能需要在 nginx 中对链接进行格式转换。

        location / {
                try_files $uri $uri/ /index.php?$query_string;
                if (!-e $request_filename) {
                        rewrite ^/index.php/(.*)$ /index.php?s=$1 last;
                        rewrite ^/(.*)$ /index.php?s=$1 last;
                }
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        }

修改之后,访问网站的各个页面就正常了。

注:

我是一名山东烟台的开发者,联系作者