修正Url类路由分组的情况

This commit is contained in:
thinkphp
2016-05-10 11:57:35 +08:00
parent 054af31455
commit 6cec513b10

View File

@@ -150,21 +150,22 @@ 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()); $domains = Route::domain();
foreach($route_domain as $domain_prefix) { $route_domain = array_keys($domains);
if(strpos($domain, trim($domain_prefix, '*.')) !== false) { foreach ($route_domain as $domain_prefix) {
foreach (Route::domain() as $key => $rule) { if (0 === strpos($domain_prefix, '*.') && strpos($domain, ltrim($domain_prefix, '*.')) !== false) {
foreach ($domains 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)) {
$url = ltrim($url, $rule); $url = ltrim($url, $rule);
$domain = $key; $domain = $key;
// 生成对应子域名 // 生成对应子域名
if(!empty($urlDomainRoot)){ if (!empty($urlDomainRoot)) {
$domain .= $urlDomainRoot; $domain .= $urlDomainRoot;
} }
break; break;
}else if(false !== strpos($key, '*')){ } else if (false !== strpos($key, '*')) {
if(!empty($urlDomainRoot)){ if (!empty($urlDomainRoot)) {
$domain .= $urlDomainRoot; $domain .= $urlDomainRoot;
} }
break; break;
@@ -269,7 +270,9 @@ class Url
if (is_numeric($key)) { if (is_numeric($key)) {
$key = array_shift($route); $key = array_shift($route);
} }
$route = $route[0]; if (is_array($route)) {
$route = $route[0];
}
$param = []; $param = [];
if (is_array($route)) { if (is_array($route)) {
$route = implode('\\', $route); $route = implode('\\', $route);