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;