diff --git a/core/Controller/UnifiedSearchController.php b/core/Controller/UnifiedSearchController.php index c2949ce6095..2930e4840ce 100644 --- a/core/Controller/UnifiedSearchController.php +++ b/core/Controller/UnifiedSearchController.php @@ -124,9 +124,17 @@ class UnifiedSearchController extends OCSController { if ($url !== '') { $urlParts = parse_url($url); + $urlPath = $urlParts['path']; + + // Optionally strip webroot from URL. Required for route matching on setups + // with Nextcloud in a webserver subfolder (webroot). + $webroot = \OC::$WEBROOT; + if ($webroot !== '' && substr($urlPath, 0, strlen($webroot)) === $webroot) { + $urlPath = substr($urlPath, strlen($webroot)); + } try { - $parameters = $this->router->findMatchingRoute($urlParts['path']); + $parameters = $this->router->findMatchingRoute($urlPath); // contacts.PageController.index => contacts.Page.index $route = $parameters['caller'];