From 81e44b2220c8965f16491e2d0b8f9d132fa156cc Mon Sep 17 00:00:00 2001 From: Devil Date: Wed, 21 Jul 2021 15:15:58 +0800 Subject: [PATCH] =?UTF-8?q?url=E5=A4=84=E7=90=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/app/common.php b/app/common.php index 93f055bf8..fbde3444f 100755 --- a/app/common.php +++ b/app/common.php @@ -1483,18 +1483,28 @@ function MyUrl($path, $params = []) $len = $is_api ? 4 : ($is_install ? 8 : 6); $url = str_replace('/'.$path, $join.substr($path, $len), $url); - // 避免从后台生成url入口错误 - if((!in_array($script_name, ['index.php', 'api.php'])) && substr($path, 0, 6) != 'admin/' && substr($path, 0, 8) != 'install/') + // 避免非当前目录生成url索引错误 + if($script_name != 'index.php' && $is_index) { - // api、install模块、url模式=兼容模式 - if($is_api || $is_install || $url_model == 0) + // 替换索引为 index.php + if($url_model == 0) { - $url = str_replace($script_name, $index, $url); + $url = str_replace($script_name, 'index.php', $url); } else { - // index并且不是兼容模式则去除入口和?s= + // url模式!=兼容模式 则去除入口和?s= $url = str_replace($script_name.'?s=', '', $url); } } + // 替换索引为 api.php + if($script_name != 'api.php' && $is_api) + { + $url = str_replace($script_name, 'api.php', $url); + } + // 替换索引为 install.php + if($script_name != 'install.php' && $is_install) + { + $url = str_replace($script_name, 'install.php', $url); + } // 前端则去除 index.php $url = str_replace('/index.php', '', $url);