mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
app路由检测改进 支持对 根目录 / 访问设置路由
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user