From 1c614d9da9fbc966cca4dc05b4aa6939f1c681ff Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 5 Jan 2016 16:14:20 +0800 Subject: [PATCH] =?UTF-8?q?app=E8=B7=AF=E7=94=B1=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E6=94=AF=E6=8C=81=E5=AF=B9=20=E6=A0=B9?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=20/=20=E8=AE=BF=E9=97=AE=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/App.php | 39 ++++++++++++++++++--------------------- library/think/Route.php | 9 +++++---- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/library/think/App.php b/library/think/App.php index d63f1a0c..2da45364 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -392,7 +392,6 @@ class App $_SERVER['PATH_INFO'] = ''; define('__INFO__', ''); define('__EXT__', ''); - $result = ['type' => 'module', 'data' => [null, null, null], 'bind' => []]; } else { $_SERVER['PATH_INFO'] = trim($_SERVER['PATH_INFO'], '/'); define('__INFO__', $_SERVER['PATH_INFO']); @@ -404,29 +403,27 @@ class App } // 去除正常的URL后缀 $_SERVER['PATH_INFO'] = preg_replace($config['url_html_suffix'] ? '/\.(' . trim($config['url_html_suffix'], '.') . ')$/i' : '/\.' . __EXT__ . '$/i', '', __INFO__); - $depr = $config['pathinfo_depr']; - // 还原劫持后真实pathinfo - $path_info = $_SERVER['PATH_INFO']; + } - // 路由检测 - if (!empty($config['url_route_on'])) { - // 开启路由 注册路由定义文件 - Route::register(!empty($config['route']) ? $config['route'] : null); - // 路由检测(根据路由定义返回不同的URL调度) - $result = Route::check($path_info, $depr); - if (false === $result) { - // 路由无效 - if ($config['url_route_must']) { - throw new Exception('route not define '); - } else { - // 继续分析为模块/控制器/操作/参数...方式URL - $result = Route::parseUrl($path_info, $depr); - } + $depr = $config['pathinfo_depr']; + // 路由检测 + if (!empty($config['url_route_on'])) { + // 开启路由 注册路由定义文件 + Route::register(!empty($config['route']) ? $config['route'] : null); + // 路由检测(根据路由定义返回不同的URL调度) + $result = Route::check($_SERVER['PATH_INFO'], $depr); + if (false === $result) { + // 路由无效 + if ($config['url_route_must']) { + throw new Exception('route not define '); + } else { + // 继续分析为模块/控制器/操作/参数...方式URL + $result = Route::parseUrl($_SERVER['PATH_INFO'], $depr); } - } else { - // 分析URL地址 采用 模块/控制器/操作/参数... - $result = Route::parseUrl($path_info, $depr); } + } else { + // 分析URL地址 采用 模块/控制器/操作/参数... + $result = Route::parseUrl($_SERVER['PATH_INFO'], $depr); } // 注册调度机制 self::dispatch($result); diff --git a/library/think/Route.php b/library/think/Route.php index a2f6a72e..31939f11 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -241,15 +241,16 @@ class Route // 检测域名部署 self::checkDomain(); + if (isset(self::$bind['module'])) { + // 如果有模块/控制器绑定 + $url = implode('/', self::$bind['module']) . '/' . $url; + } + // 优先检测是否存在PATH_INFO if (empty($url)) { $url = '/'; } - if (isset(self::$bind['module'])) { - $url = implode('/', self::$bind['module']) . '/' . $url; - } - // 分隔符替换 确保路由定义使用统一的分隔符 if ('/' != $depr) { $url = str_replace($depr, '/', $url);