内容详情
1.开启配置config.php
'url_param_type' => 0,
// 是否开启路由
'url_route_on' => true,
// 路由使用完整匹配
'route_complete_match' => true,
// 路由配置文件(支持配置多个)
'route_config_file' => ['route'],
// 是否强制使用路由
'url_route_must' => true,
2.使用route.php;
use think\Route;
// 注册路由到index模块的News控制器的read操作
Route::get('/index','index/index/index');
Route::get('/dome','index/index/dome');
3.创建Index控制器index和dome方法;
1 <?php
2 namespace app\index\controller;
3
4 use think\Controller;
5 use GatewayClient\Gateway;
6 use think\Route;
7 class Index extends Controller
8 {
9 public function index()
10 {
11
12 echo "321";
13 }
14 public function dome()
15 {
16 echo "123";
17
18 }
19
20
21 }
22
4.访问http://127.0.0.1/index
如果出现File not found. 请你修改.htaccess文件
1 Options +FollowSymlinks
2 RewriteEngine On
3 RewriteCond %{REQUEST_FILENAME} !-d
4 RewriteCond %{REQUEST_FILENAME} !-f
5 RewriteRule ^(.*)${content}nbsp;index.php/$1 [QSA,PT,L]
改.为
1
2 RewriteEngine on
3 RewriteCond %{REQUEST_FILENAME} !-d
4 RewriteCond %{REQUEST_FILENAME} !-f
5 RewriteRule ^(.*)${content}nbsp;index.php?s=/$1 [QSA,PT,L]