diff --git a/extend/hook/FilterView.php b/extend/hook/FilterView.php index 92319644f..b38817bf9 100644 --- a/extend/hook/FilterView.php +++ b/extend/hook/FilterView.php @@ -40,7 +40,7 @@ class FilterView { $this->request = Request::instance(); list($appRoot, $uriSelf) = [$this->request->root(true), $this->request->url(true)]; - $uriRoot = strpos($appRoot, EXT) ? ltrim(dirname($appRoot), DS) : $appRoot; + $uriRoot = preg_match('/\.php$/', $appRoot) ? dirname($appRoot) : $appRoot; $uriStatic = "{$uriRoot}/static"; $replace = ['__APP__' => $appRoot, '__SELF__' => $uriSelf, '__PUBLIC__' => $uriRoot, '__STATIC__' => $uriStatic]; $params = str_replace(array_keys($replace), array_values($replace), $params); diff --git a/extend/service/FileService.php b/extend/service/FileService.php index 2fde733fe..bbd3446ee 100644 --- a/extend/service/FileService.php +++ b/extend/service/FileService.php @@ -131,13 +131,9 @@ class FileService */ public static function getBaseUriLocal() { - $request = request(); - $base = $request->root(); - $root = strpos($base, '.') ? ltrim(dirname($base), DS) : $base; - if ('' != $root) { - $root = '/' . ltrim($root, '/'); - } - return ($request->isSsl() ? 'https' : 'http') . '://' . $request->host() . "{$root}/static/upload/"; + $appRoot = request()->root(true); + $uriRoot = preg_match('/\.php$/', $appRoot) ? dirname($appRoot) : $appRoot; + return "{$uriRoot}/static/upload/"; } /**