From a4843dd1a338de0cad0b36b22ea34bd9ae749c71 Mon Sep 17 00:00:00 2001 From: shenfakuan Date: Fri, 29 Apr 2016 14:39:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=A8=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=E8=B7=AF=E7=94=B1=E6=97=B6=EF=BC=8Curl?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=BB=93=E6=9E=9C=E4=B8=8D=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Url.php | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/library/think/Url.php b/library/think/Url.php index d4738bc5..be09ab08 100644 --- a/library/think/Url.php +++ b/library/think/Url.php @@ -150,22 +150,26 @@ class Url if (Config::get('url_domain_deploy')) { // 根域名 $urlDomainRoot = Config::get('url_domain_root'); - foreach (Route::domain() as $key => $rule) { - $rule = is_array($rule) ? $rule[0] : $rule; - if (false === strpos($key, '*') && 0 === strpos($url, $rule)) { - $url = ltrim($url, $rule); - $domain = $key; - // 生成对应子域名 - if(!empty($urlDomainRoot)){ - $domain .= $urlDomainRoot; + $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) { + $rule = is_array($rule) ? $rule[0] : $rule; + if (false === strpos($key, '*') && 0 === strpos($url, $rule)) { + $url = ltrim($url, $rule); + $domain = $key; + // 生成对应子域名 + if(!empty($urlDomainRoot)){ + $domain .= $urlDomainRoot; + } + break; + }else if(false !== strpos($key, '*')){ + if(!empty($urlDomainRoot)){ + $domain .= $urlDomainRoot; + } + break; + } } - break; - }else if(false !== strpos($key, '*')){ - $domain = str_replace('*',strstr($domain,'.',true),$key); - if(!empty($urlDomainRoot)){ - $domain .= $urlDomainRoot; - } - break; } } }