diff --git a/library/think/app.php b/library/think/app.php index b6a7ced8..8cd37249 100644 --- a/library/think/app.php +++ b/library/think/app.php @@ -251,7 +251,10 @@ class App // 检测域名部署 if (!IS_CLI && !empty($config['url_domain_deploy'])) { - if ($match = Route::checkDomain($config['url_domain_rules'])) { + if ($config['url_domain_rules']) { + Route::domain($config['url_domain_rules']); + } + if ($match = Route::checkDomain()) { (!defined('BIND_MODULE') && !empty($match[0])) && define('BIND_MODULE', $match[0]); (!defined('BIND_CONTROLLER') && !empty($match[1])) && define('BIND_CONTROLLER', $match[1]); (!defined('BIND_ACTION') && !empty($match[2])) && define('BIND_ACTION', $match[2]); @@ -292,10 +295,10 @@ class App $depr = $config['pathinfo_depr']; // 还原劫持后真实pathinfo $path_info = - (defined('BIND_MODULE') ? BIND_MODULE . $depr : '') . - (defined('BIND_CONTROLLER') ? BIND_CONTROLLER . $depr : '') . - (defined('BIND_ACTION') ? BIND_ACTION . $depr : '') . - $_SERVER['PATH_INFO']; + (defined('BIND_MODULE') ? BIND_MODULE . $depr : '') . + (defined('BIND_CONTROLLER') ? BIND_CONTROLLER . $depr : '') . + (defined('BIND_ACTION') ? BIND_ACTION . $depr : '') . + $_SERVER['PATH_INFO']; // 路由检测 if (!empty($config['url_route_on'])) { diff --git a/library/think/url.php b/library/think/url.php index 1157bc9b..fe8e38a4 100644 --- a/library/think/url.php +++ b/library/think/url.php @@ -139,9 +139,10 @@ class Url $domain = 'localhost' == $domain ? 'localhost' : 'www' . strstr($_SERVER['HTTP_HOST'], '.'); // '子域名'=>array('项目[/分组]'); foreach (Config::get('url_domain_rules') as $key => $rule) { - if (false === strpos($key, '*') && 0 === strpos($url, $rule[0])) { + $rule = is_array($rule) ? $rule[0] : $rule; + if (false === strpos($key, '*') && 0 === strpos($url, $rule)) { $domain = $key . strstr($domain, '.'); // 生成对应子域名 - $url = substr_replace($url, '', 0, strlen($rule[0])); + $url = substr_replace($url, '', 0, strlen($rule)); break; } }