http://www.x.com/index.php/index/index/do.html?sale=xxx
变成
http://www.x.com/do.html?sale=xxx
1.首先你要先隐藏index.php入口文件,手册里有比较简单。
2.config/app.php里启用路由
// 是否启用路由
'with_route' => true,
// 默认应用
'default_app' => 'index',
3.在app/应用目录/route/app.php里添加路由规则
Route::rule('domain', 'index/domain');
4.修改入口文件index.php
$response = $http->run();
改为
$_other = 'admin|asrws'; // 这里是除了绑定以外的所有其他应用
if (preg_match('/^\/('.$_other.')\/?/', $_SERVER['REQUEST_URI'])) {
$response = $http->run();
} else {
$response = $http->name('index')->run(); //默认绑定应用
}
注意这里的$_other的应用名不要出现在其他url的应用名或控制器或方法里,以免出现混乱