From 362be0ae3e2358b84f6e985a0a7ec16b7cb1db84 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 21 Dec 2015 21:27:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3URL=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=AF=B9=E5=AD=90=E5=9F=9F=E5=90=8D=E9=83=A8=E7=BD=B2=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/app.php | 13 ++++++++----- library/think/url.php | 5 +++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/library/think/app.php b/library/think/app.php index b6a7ced8..8cd37249 100644 --- a/library/think/app.php +++ b/library/think/app.php @@ -251,7 +251,10 @@ class App // 检测域名部署 if (!IS_CLI && !empty($config['url_domain_deploy'])) { - if ($match = Route::checkDomain($config['url_domain_rules'])) { + if ($config['url_domain_rules']) { + Route::domain($config['url_domain_rules']); + } + if ($match = Route::checkDomain()) { (!defined('BIND_MODULE') && !empty($match[0])) && define('BIND_MODULE', $match[0]); (!defined('BIND_CONTROLLER') && !empty($match[1])) && define('BIND_CONTROLLER', $match[1]); (!defined('BIND_ACTION') && !empty($match[2])) && define('BIND_ACTION', $match[2]); @@ -292,10 +295,10 @@ class App $depr = $config['pathinfo_depr']; // 还原劫持后真实pathinfo $path_info = - (defined('BIND_MODULE') ? BIND_MODULE . $depr : '') . - (defined('BIND_CONTROLLER') ? BIND_CONTROLLER . $depr : '') . - (defined('BIND_ACTION') ? BIND_ACTION . $depr : '') . - $_SERVER['PATH_INFO']; + (defined('BIND_MODULE') ? BIND_MODULE . $depr : '') . + (defined('BIND_CONTROLLER') ? BIND_CONTROLLER . $depr : '') . + (defined('BIND_ACTION') ? BIND_ACTION . $depr : '') . + $_SERVER['PATH_INFO']; // 路由检测 if (!empty($config['url_route_on'])) { diff --git a/library/think/url.php b/library/think/url.php index 1157bc9b..fe8e38a4 100644 --- a/library/think/url.php +++ b/library/think/url.php @@ -139,9 +139,10 @@ class Url $domain = 'localhost' == $domain ? 'localhost' : 'www' . strstr($_SERVER['HTTP_HOST'], '.'); // '子域名'=>array('项目[/分组]'); foreach (Config::get('url_domain_rules') as $key => $rule) { - if (false === strpos($key, '*') && 0 === strpos($url, $rule[0])) { + $rule = is_array($rule) ? $rule[0] : $rule; + if (false === strpos($key, '*') && 0 === strpos($url, $rule)) { $domain = $key . strstr($domain, '.'); // 生成对应子域名 - $url = substr_replace($url, '', 0, strlen($rule[0])); + $url = substr_replace($url, '', 0, strlen($rule)); break; } }