修正URL生成对子域名部署的支持

This commit is contained in:
thinkphp
2015-12-21 21:27:42 +08:00
parent 46fdf4aa14
commit 362be0ae3e
2 changed files with 11 additions and 7 deletions

View File

@@ -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'])) {

View File

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