From f9ff3dcfdc053a9363d61c6ee302538ba3319ea2 Mon Sep 17 00:00:00 2001 From: huangdijia Date: Fri, 15 Jan 2016 09:52:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AD=90=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=EF=BC=8C=E6=94=AF=E6=8C=81=E7=9F=AD=E5=BC=8F?= =?UTF-8?q?=E5=AD=90=E5=9F=9F=E5=90=8D=EF=BC=88=E5=A6=82=EF=BC=9Auser?= =?UTF-8?q?=EF=BC=89=E3=80=81=E5=AE=8C=E6=95=B4=E5=AD=90=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=EF=BC=88user.tp.cn=EF=BC=89=20http://tp.cn=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=85=A8=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/library/think/Route.php b/library/think/Route.php index f386c451..c2e2cc4f 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -37,6 +37,8 @@ class Route private static $map = []; // 子域名部署规则 private static $domain = []; + // 子域名 + private static $subDomain = ''; // 变量规则 private static $pattern = []; // 域名绑定 @@ -249,8 +251,11 @@ class Route } // 子域名配置 if (!empty($domain)) { + // 记录子域名 + self::$subDomain = $domain; + // 二级域名 $subDomain = implode('.', $domain); - $domain2 = array_pop($domain); // 二级域名 + $domain2 = array_pop($domain); if ($domain) { // 存在三级域名 $domain3 = array_pop($domain); @@ -441,7 +446,7 @@ class Route // 请求类型检测 if ((isset($option['method']) && false === stripos($option['method'], REQUEST_METHOD)) || (isset($option['ext']) && false === stripos($option['ext'], __EXT__)) // 伪静态后缀检测 - || (isset($option['domain']) && 0 === stripos($option['domain'] . '.', $_SERVER['HTTP_HOST'])) // 域名检测 + || (isset($option['domain']) && !in_array($option['domain'], [$_SERVER['HTTP_HOST'], self::$subDomain])) // 域名检测 || (!empty($option['https']) && !self::isSsl()) // https检测 || (!empty($option['behavior']) && false === Hook::exec($option['behavior'])) // 行为检测 || (!empty($option['callback']) && is_callable($option['callback']) && false === call_user_func($option['callback'])) // 自定义检测