修复域名部署情况下,url生成 多出module_name的问题

This commit is contained in:
cjango
2016-04-23 15:32:25 +08:00
parent 670bc43c62
commit c21a1b8b06

View File

@@ -26,6 +26,9 @@ class Url
*/
public static function build($url = '', $vars = '', $suffix = true, $domain = false)
{
if (is_bool($domain) && Config::get('url_domain_deploy')) {
$domain = true;
}
// 解析URL
$info = parse_url($url);
$url = !empty($info['path']) ? $info['path'] : '';
@@ -101,7 +104,6 @@ class Url
} else {
$url .= $suffix . $anchor;
}
// 检测域名
$domain = self::parseDomain($url, $domain);
// URL组装
@@ -139,7 +141,7 @@ class Url
}
// 检测域名
protected static function parseDomain($url, $domain)
protected static function parseDomain(&$url, $domain)
{
if ($domain) {
if (true === $domain) {
@@ -151,6 +153,7 @@ class Url
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 . strstr($domain, '.'); // 生成对应子域名
break;
}