From 5fcb550c2c917d2b97926bc0811b643623ebc402 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 24 Aug 2016 12:39:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BUrl=E7=B1=BB=E7=9A=84parseDom?= =?UTF-8?q?ain=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Url.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/library/think/Url.php b/library/think/Url.php index b2765785..ea690e76 100644 --- a/library/think/Url.php +++ b/library/think/Url.php @@ -209,8 +209,13 @@ class Url } } } - } else { - $domain .= strpos($domain, '.') ? '' : strstr($request->host(), '.'); + } elseif (!strpos($domain, '.')) { + $rootDomain = Config::get('url_domain_root'); + if (empty($rootDomain)) { + $host = $request->host(); + $rootDomain = substr_count($host, '.') > 1 ? substr(strstr($host, '.'), 1) : $host; + } + $domain .= '.' . $rootDomain; } return ($request->isSsl() ? 'https://' : 'http://') . $domain; }