[PHP] thinkphp5 单入口多个模块绑定和路由开关

thinkphp5 单入口多个模块绑定和路由开关

index.php

入口代码如下:

// 定义应用目录
define('APP_PATH', __DIR__ . '/../app/');
 
require __DIR__ . '/../thinkphp/base.php';// 加载框架基础文件
//开启域名部署后
switch ($_SERVER['HTTP_HOST']) {
    case 'www.xxxx.com':
        $model = 'home';// home模块
        $route = true;// 开启路由
        break;
    case 'admin.xxxx.com':
        $model = 'admin';// admin模块
        $route = false;// 关闭路由
        break;
}
\think\Route::bind($model ?? 'home');// 绑定当前入口文件到模块
\think\App::route($route ?? true);// 路由
\think\App::run()->send();// 执行应用

参考:https://blog.csdn.net/xiaowan206/article/details/78052773

本博客地址: wukong1688

本文原文地址:https://www.cnblogs.com/wukong1688/p/12309373.html

转载请著名出处!谢谢~~

猜你喜欢

转载自www.cnblogs.com/wukong1688/p/12309373.html