单应用模式访问
域名/index.php/控制器/操作/参数/值...
多应用模式访问
域名/index.php/应用/控制器/操作/参数/值...
比如我们想访问这个函数
index.php=入口文件,admin=应用 , index=控制器, hello=操作 ,name=参数 张三=值
xuexi.io/index.php/admin/index/hello/name/张三
隐藏入口文件
代码1
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>
代码2
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
将代码粘贴到这个目录下面 如果代码1使用不了 可以使用代码2
绑定专属域名
检查一下 是否启用路由改成 true
自定义路由
<?php
use think\facade\Route;
Route::get('/', 'Index/index');
浏览器输入 xuexi.io/api 就可以访问了
隐藏应用名