Apache 隐藏 index.php,如将 tp5.com/index.php/hello/123 变成 tp5.com/hello/123

 
 
 
以Apache为例,需要在index.php入口文件的同级添加.htaccess文件,内容如下:
<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On
 
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
如果用的 phpstudy,规则如下:
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>
原文地址:https://www.cnblogs.com/CyLee/p/9380905.html