Merge pull request #51 from shenfakuan/master

修改在使用域名路由时,url方法结果不正确的bug(优化parseDomain)
This commit is contained in:
ThinkPHP
2016-05-08 08:44:52 +08:00

View File

@@ -150,6 +150,9 @@ class Url
if (Config::get('url_domain_deploy')) { if (Config::get('url_domain_deploy')) {
// 根域名 // 根域名
$urlDomainRoot = Config::get('url_domain_root'); $urlDomainRoot = Config::get('url_domain_root');
$route_domain = array_keys(Route::domain());
foreach($route_domain as $domain_prefix) {
if(strpos($domain, trim($domain_prefix, '*.')) !== false) {
foreach (Route::domain() as $key => $rule) { foreach (Route::domain() as $key => $rule) {
$rule = is_array($rule) ? $rule[0] : $rule; $rule = is_array($rule) ? $rule[0] : $rule;
if (false === strpos($key, '*') && 0 === strpos($url, $rule)) { if (false === strpos($key, '*') && 0 === strpos($url, $rule)) {
@@ -161,7 +164,6 @@ class Url
} }
break; break;
}else if(false !== strpos($key, '*')){ }else if(false !== strpos($key, '*')){
$domain = str_replace('*',strstr($domain,'.',true),$key);
if(!empty($urlDomainRoot)){ if(!empty($urlDomainRoot)){
$domain .= $urlDomainRoot; $domain .= $urlDomainRoot;
} }
@@ -169,6 +171,8 @@ class Url
} }
} }
} }
}
}
} else { } else {
$domain .= strpos($domain, '.') ? '' : strstr($_SERVER['HTTP_HOST'], '.'); $domain .= strpos($domain, '.') ? '' : strstr($_SERVER['HTTP_HOST'], '.');
} }