thinkphp6 Nginx访问环境所有路由都显示首页

Song1575 次浏览0个评论2022年02月18日

Mac环境中的Nginx配置环境后无论访问任何路由都只显示首页,百度后解决办法如下:

server{
        listen 80;
        server_name tptest.cn;
        index index.php index.html index.htm;
        root  /var/www/tp6test/public;

        #autoindex on;
        if (!-e $request_filename) {
            rewrite ^(.*)$ /index.php?s=/$1 last;
            break;
        }

        location ~ \.php$ {
                try_files $uri /index.php =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
        location ~ /\.ht {
                deny all;
        }

        location / {
          try_files $uri $uri/ /index.php?$query_string;
        }
}

主要的操作就是配置了:

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

提交评论

请登录后评论

用户评论

    当前暂无评价,快来发表您的观点吧...

更多相关好文