tp5路由配置文件

例如工具站会遇到多个二级域名指向同一个模块下不同控制器:

在application/route.php加上

':action/:c/:a'=> ':action/:c/:a',

config.php:

// 是否开启路由
    'url_route_on'           => true,

在入口文件中添加


// 定义应用目录
define('APP_PATH', __DIR__ . '/../application/');

//开启域名部署后
// exit($_SERVER['HTTP_HOST']);

switch ($_SERVER['HTTP_HOST']) {
    case 'secret.tool.com':
        $model = 'index/Secret/index';   // 生成随机密码模块
        $route = false;// 开启路由
        break;
    case 'picture.tool.com':
        $model = 'index/picture/index';// 压缩图片模块
        $route = false;// 关闭路由
        break;
};
define('BIND_MODULE',$model);

// 加载框架引导文件
require __DIR__ . '/../thinkphp/start.php';

-----------------------------------------------------------------------------------------------------

如果要实现多个域名指向多个模块

在config.php中添加

开启路由

    'url_route_on'           => true,

   \think\Route::domain('secret.tool.com','index/Secret/index'),    //模块名
   \think\Route::domain('picture.tool.com','index/Picture/index'),

----------------------------------------------------------------------------------------

简化tp5路由

在route.php的return中加上

'vpn'=> 'index/index/vpn',
'socks5'=> 'index/index/index',

每个方法对应一个配置项,<a href="vpn" class=....

猜你喜欢

转载自blog.csdn.net/lorraine_40t/article/details/81067190