改进Url类的parseDomain方法

This commit is contained in:
thinkphp
2016-08-24 12:39:23 +08:00
parent 242c8bf7c6
commit 5fcb550c2c

View File

@@ -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;
}