diff --git a/library/think/app.php b/library/think/app.php index 316b1558..56a6e7f0 100644 --- a/library/think/app.php +++ b/library/think/app.php @@ -266,25 +266,27 @@ class App // URL后缀 define('__EXT__', strtolower(pathinfo($_SERVER['PATH_INFO'], PATHINFO_EXTENSION))); $_SERVER['PATH_INFO'] = __INFO__; - if (__INFO__ && !defined('BIND_MODULE')) { + if (__INFO__) { if ($config['url_deny_suffix'] && preg_match('/\.(' . $config['url_deny_suffix'] . ')$/i', __INFO__)) { throw new Exception('URL_SUFFIX_DENY'); } + // 还原劫持后真实pathinfo + $path_info = (defined('BIND_MODULE')?BIND_MODULE.'/':'') . (defined('BIND_CONTROLLER')?BIND_CONTROLLER.'/':'') . (defined('BIND_ACTION')?BIND_ACTION.'/':'') . __INFO__; // 路由检测 if (!empty($config['url_route_on'])) { // 开启路由 则检测路由配置 Route::register($config['route']); - $result = Route::check(__INFO__, $config['pathinfo_depr']); + $result = Route::check($path_info, $config['pathinfo_depr']); if (false === $result) { // 路由无效 if ($config['url_route_must']) { throw new Exception('route not define '); } else { - $result = Route::parseUrl(__INFO__); + $result = Route::parseUrl($path_info); } } } else { - $result = Route::parseUrl(__INFO__); + $result = Route::parseUrl($path_info); } } // 去除URL后缀 diff --git a/library/think/route.php b/library/think/route.php index c755b175..ec586cf0 100644 --- a/library/think/route.php +++ b/library/think/route.php @@ -435,20 +435,27 @@ class Route if (false !== strpos($url, '?')) { // [控制器/操作?]参数1=值1&参数2=值2... $info = parse_url($url); - $path = explode('/', $info['path']); + $path = explode('/', $info['path'], 4); parse_str($info['query'], $var); } elseif (strpos($url, '/')) { // [控制器/操作] - $path = explode('/', $url); + $path = explode('/', $url, 4); } else { // 参数1=值1&参数2=值2... parse_str($url, $var); } if (isset($path)) { + $param = []; + if(!empty($path[3])) $param = explode('/', array_pop($path)); + // 解析[模块/控制器/操作] $action = array_pop($path); $action = '[rest]' == $action ? REQUEST_METHOD : $action; $controller = !empty($path) ? array_pop($path) : null; $module = !empty($path) ? array_pop($path) : null; + // 解析path额外的参数 + for ($i=0; $i [$module, $controller, $action], 'var' => $var]; }