From ab2222b100e8dfa81c379a0df688f2947458cd77 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 22 May 2017 14:43:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=91=BD=E4=BB=A4=E8=A1=8C?= =?UTF-8?q?=E4=B8=8B=E9=9D=A2=E7=9A=84URL=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- convention.php | 4 ++-- library/think/Request.php | 4 +--- library/think/Url.php | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/convention.php b/convention.php index 00ed0452..62ab0ea4 100644 --- a/convention.php +++ b/convention.php @@ -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中的控制器和操作名 diff --git a/library/think/Request.php b/library/think/Request.php index 2712c742..13089576 100644 --- a/library/think/Request.php +++ b/library/think/Request.php @@ -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'); } diff --git a/library/think/Url.php b/library/think/Url.php index 8e716a5b..24a2b4e3 100644 --- a/library/think/Url.php +++ b/library/think/Url.php @@ -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)) {