thinkphp6 多入口文件的应用和隐藏

1.在public下建2个入口文件,分别是

admin.php     代表后台

index.php     代表前台

2.在route文件下,分别建前后台的路由文件

admin/app.php

<?php

use think\facade\Route;
Route::get('admin/', 'index/index');
Route::get('admin/weclome', 'index/weclome')->name('weclome');

index/route.php

<?php

use think\facade\Route;
Route::get('', 'index/index');
Route::get('hello', 'index/hello');

3.public 目录下的.htaccess文件里如下图这样写

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^admin(.*)$ admin.php [L,E=PATH_INFO:$1]
  RewriteRule !^index(.*)$ index.php/index/ [L,E=PATH_INFO:$1]
</IfModule>

到这里多入口应用入口文件就隐藏了,试试吧

发布了36 篇原创文章 · 获赞 8 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/weixin_41965172/article/details/104465497