From bc08a8cdcfff9a3f33458c88e49c99f912d45483 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 14 Jan 2016 13:50:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E5=88=B0=E6=8E=A7=E5=88=B6=E5=99=A8=E7=9A=84=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/library/think/Route.php b/library/think/Route.php index 50047678..5e9ef8a8 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -559,24 +559,25 @@ class Route } } if (0 === strpos($url, '/') || 0 === strpos($url, 'http')) { - // 路由重定向跳转 if (strpos($url, ':')) { // 传递动态参数 $values = array_values($matches); $url = preg_replace('/:(\d+)/e', '$values[\\1-1]', $url); } + // 路由到重定向地址 $result = ['type' => 'redirect', 'url' => $url, 'status' => (is_array($route) && isset($route[1])) ? $route[1] : 301]; } elseif (0 === strpos($url, '\\')) { // 路由到方法 $result = ['type' => 'method', 'method' => $route, 'params' => $matches]; } elseif (0 === strpos($url, '@')) { - // 路由到控制器 - if (strpos($url, ':')) { - // 传递动态参数 - foreach ($matches as $key => $val) { + // 传递动态参数 + foreach ($matches as $key => $val) { + if (strpos($url, ':' . $key)) { $url = str_replace(':' . $key, $val, $url); + unset($matches[$key]); } } + // 路由到控制器 $result = ['type' => 'controller', 'controller' => substr($url, 1), 'params' => $matches]; } else { // 解析路由地址 @@ -594,6 +595,7 @@ class Route $var = array_merge($matches, $result['var']); // 解析剩余的URL参数 self::parseUrlParams(implode('/', $paths), $var); + // 路由到模块/控制器/操作 $result = ['type' => 'module', 'module' => $result['route']]; } return $result;