改进命令行下面的URL生成

This commit is contained in:
thinkphp
2017-05-22 14:43:42 +08:00
parent 8b2a7546e0
commit ab2222b100
3 changed files with 5 additions and 7 deletions

View File

@@ -89,8 +89,8 @@ return [
'url_route_must' => false,
// 域名部署
'url_domain_deploy' => false,
// 当前默认URL根地址
'default_url_root' => '',
// 默认Host地址
'default_host' => '',
// 域名根如thinkphp.cn
'url_domain_root' => '',
// 是否自动转换URL中的控制器和操作名

View File

@@ -132,9 +132,7 @@ class Request
if (is_null($this->filter)) {
$this->filter = Config::get('default_filter');
}
if (Config::get('default_url_root')) {
$this->root(Config::get('default_url_root'));
}
// 保存 php://input
$this->input = file_get_contents('php://input');
}

View File

@@ -235,7 +235,7 @@ class Url
$rootDomain = Config::get('url_domain_root');
if (true === $domain) {
// 自动判断域名
$domain = $request->host();
$domain = Config::get('default_host') ?: $request->host();
$domains = Route::rules('domain');
if ($domains) {
@@ -265,7 +265,7 @@ class Url
} else {
if (empty($rootDomain)) {
$host = $request->host();
$host = Config::get('default_host') ?: $request->host();
$rootDomain = substr_count($host, '.') > 1 ? substr(strstr($host, '.'), 1) : $host;
}
if (substr_count($domain, '.') < 2 && !strpos($domain, $rootDomain)) {