diff --git a/classes/Factory/ViewFactory.php b/classes/Factory/ViewFactory.php index 1b9fe6c2..52715f4f 100644 --- a/classes/Factory/ViewFactory.php +++ b/classes/Factory/ViewFactory.php @@ -45,12 +45,21 @@ private static function cleanBasePath(Uri $uri): Uri { $basePath = $uri->getBasePath(); if (str_ends_with($basePath, 'index.php')) { + $basePath = dirname($basePath); + if ($basePath == '/') { + /* + * Calling withBasePath('/') does nothing, + * we have to use an empty string instead. + */ + $basePath = ''; + } + /* * When the base path ends with index.php, * routing works correctly, but it breaks the URL of static assets using {base_url}. * So we alter the base path but only in the URI used by SmartyPlugins. */ - $uri = $uri->withBasePath(dirname($basePath)); + $uri = $uri->withBasePath($basePath); } return $uri;