改进子域名路由

This commit is contained in:
thinkphp
2015-12-21 22:02:36 +08:00
parent 2c0240cd42
commit 6b42f979ef
2 changed files with 9 additions and 7 deletions

View File

@@ -137,8 +137,8 @@ class Url
if (Config::get('url_domain_deploy')) {
// 开启子域名部署
$domain = 'localhost' == $domain ? 'localhost' : 'www' . strstr($_SERVER['HTTP_HOST'], '.');
// '子域名'=>array('项目[/分组]');
foreach (Config::get('url_domain_rules') as $key => $rule) {
// '子域名'=>['模块[/控制器/操作]'];
foreach (Route::domain() as $key => $rule) {
$rule = is_array($rule) ? $rule[0] : $rule;
if (false === strpos($key, '*') && 0 === strpos($url, $rule)) {
$domain = $key . strstr($domain, '.'); // 生成对应子域名