天天看点

tp5隐藏index.php的方法

配置的路由为:

use think\Route;
Route::group('index',function(){
	Route::get('index',"@home/Index/index");
});
           

请求的结果为: 

tp5隐藏index.php的方法

添加index.php后请求结果为

tp5隐藏index.php的方法

找到public文件夹下的.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>
           

修改方式

将RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]修改为RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
           

再次请求,结果为

tp5隐藏index.php的方法