在使用 ThinkPHP6 和 Nginx 时,需要进行伪静态的设置,以便更好地优化网站的访问速度和搜索引擎的收录。具体的设置方法如下:

  1. 在 Nginx 的配置文件中添加以下代码:
location / {
    if (!-e $request_filename) {
        rewrite ^/(.*)$ /index.php/$1 last;
    }
}
  1. 在 ThinkPHP6 的配置文件(位于 config 目录下)中,将 url_route_on 设置为 true,并将 url_route_must 设置为 false
return [
    // ...
    'url_route_on' => true,
    'url_route_must' => false,
    // ...
];
  1. 如果没有 .env 文件,可以在 config 目录下的 app.php 中设置 app_debugtrue
return [
    // ...
    'app_debug' => true,
    // ...
];

以上是 ThinkPHP6 和 Nginx 伪静态的设置方法,希望能对您有所帮助

thinkphp6 nginx伪静态需要设置吗怎么设置没有env文件app_debug怎么开

原文地址: https://www.cveoy.top/t/topic/fnPj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录