tp5实现绑定子域名,并且根据子域名定义路由规则
发布时间:2020-10-03
TP5的路由规则,可以绑定子域名到对应的模块,然后根据域名不同,使用不同的路由规则
use \think\Route;
Route::domain('admin','admin');//绑定admin子域名
Route::domain('en','en');//绑定en子域名
$request = \think\Request::instance();
$domain = $request->domain();
preg_match("#http://(.*?)\.#i", $domain, $match);
$domain=$match[1];
if($domain=='www'){
Route::get('news/:artid','index/article/index',['ext'=>'html']);
Route::get('newslist/:cateid','index/artlist/index',['ext'=>'html']);
}else if($domain=='en'){
Route::get('news/:artid','en/article/index',['ext'=>'html']);
Route::get('newslist/:cateid','en/artlist/index',['ext'=>'html']);
}else {
}
版权与免责声明君心网络声明:如发现内容存在版权问题,烦请提供相关信息发邮件至29117556@qq.com,我们将及时沟通与处理。本站内容系统部分采集于网络,涉及言论、版权与本站无关。