From c5affe33ea8ae3640a92f038c6cefdf4acf137da Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 7 Jan 2016 15:54:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=9F=9F=E5=90=8D=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E7=9A=84=E5=8F=82=E6=95=B0=E4=BC=A0=E5=85=A5=E8=A7=A3?= =?UTF-8?q?=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/library/think/Route.php b/library/think/Route.php index ed4eee2b..013e6aa8 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -217,7 +217,6 @@ class Route if (!empty($rule)) { // 子域名部署规则 // '子域名'=>'模块[/控制器/操作]' - // '子域名'=>['模块[/控制器/操作]','var1=a&var2=b&var3=*']; // '子域名'=>'模块[/控制器/操作]?var1=a&var2=b&var3=*'; if ($rule instanceof \Closure) { // 执行闭包 @@ -225,30 +224,24 @@ class Route self::$bind = $reflect->invokeArgs([]); return; } - if (is_array($rule)) { - $result = $rule[0]; - if (isset($rule[1])) { - // 传入参数 - parse_str($rule[1], $params); - if (isset($panDomain)) { - $pos = array_search('*', $params); - if (false !== $pos) { - // 泛域名作为参数 - $params[$pos] = $panDomain; - } + + if (strpos($rule, '?')) { + // 传入其它参数 + $array = parse_url($rule); + $result = $array['path']; + parse_str($array['query'], $params); + if (isset($panDomain)) { + $pos = array_search('*', $params); + if (false !== $pos) { + // 泛域名作为参数 + $params[$pos] = $panDomain; } - $_GET = array_merge($_GET, $params); } + $_GET = array_merge($_GET, $params); } else { - if (strpos($rule, '?')) { - $result = strstr($rule, '?', true); - $query = strstr($rule, '?'); - parse_str(substr($query, 1), $params); - $_GET = array_merge($_GET, $params); - }else{ - $result = $rule; - } + $result = $rule; } + if (0 === strpos($result, '\\')) { // 绑定到命名空间 例如 \app\index\behavior self::$bind = ['type' => 'namespace', 'namespace' => $result];