美文网首页
ThinkPHP6 伪静态(隐藏index.php)真正有效的方

ThinkPHP6 伪静态(隐藏index.php)真正有效的方

作者: 佛分_知合 | 来源:发表于2023-01-17 17:09 被阅读0次

网上讲了很多方法,试了都有问题,最后用这个可以了:
https://www.php.cn/blog/detail/35221.html

伪静态就是在访问url时隐藏index.php
例:
http://domain.com/index.php/admins/login/login
变成:
http://domain.com/admins/login/login

nginx

  • 根目录下新建.rewrite.conf文件
location /  {
  if  (!-e $request_filename){
    rewrite ^(.*)$ /index.php?s=$1 last;  break;
  }
}

Apache

  • 根目录新建文件.htaccess
<IfModule  mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]
</IfModule>

相关文章

网友评论

      本文标题:ThinkPHP6 伪静态(隐藏index.php)真正有效的方

      本文链接:https://www.haomeiwen.com/subject/tptxhdtx.html