绑定站点的二级域名、外部域名

pull/41/head
devlike 2018-02-08 11:05:26 +08:00
parent c2793f1fb2
commit 8bc0b5e06b
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
<?php
/**
* @desc: 动态绑定二级域名
* @Author: Dr.Xing <ezfwork@foxmail.com>
* @Since: 2018/1/28 15:18
*/
namespace seven\behavior;
use think\Route;
use think\Cache;
class BindDomain
{
public function run()
{
$rules = Cache::get('rules');
if(!$rules) {
$rules = \app\common\model\Sites::refreshRulesCache();
}
foreach($rules as $k => $v){
Route::domain($v['s'], 'index'. $v['p']);
Route::domain('admin.'.$v['s'], 'admin'. $v['p']);
}
}
}