From 2844e4093d28731532e436ee763e2b4e4ba91823 Mon Sep 17 00:00:00 2001 From: filesite Date: Thu, 11 Jul 2024 09:44:46 +0800 Subject: [PATCH] bug fix: wrong webroot for dirs --- controller/Controller.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/controller/Controller.php b/controller/Controller.php index 9df6a8c..09cdf1d 100644 --- a/controller/Controller.php +++ b/controller/Controller.php @@ -311,12 +311,12 @@ Class Controller { return "{$prefix}_{$dataType}_{$maxScanDeep}_{$cateId}"; } - protected function getCurrentWebroot($realpath) { - $realpath = preg_replace('/\/[^\/]+\.[^\/]+$/', '', $realpath); //删除文件名,只保留目录 - if (empty($realpath)) {return '/';} + //根据目录的绝对路径,获取网站的相对路径 + protected function getCurrentWebroot($dir_realpath) { + if (empty($dir_realpath)) {return '/';} $webroot = FSC::$app['config']['content_directory']; - $arr = explode($webroot, $realpath); + $arr = explode($webroot, $dir_realpath); if (count($arr) < 2) { return $webroot; }