fastadmin/extend/seven/behavior/BindDomain.php

29 lines
591 B
PHP

<?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'], $v['p']);
//Route::domain($v['s'], 'index'. $v['p']);
//Route::domain('admin.'.$v['s'], 'admin'. $v['p']);
}
}
}