diff --git a/src/services/Redirects.php b/src/services/Redirects.php index 2446abf..132be28 100644 --- a/src/services/Redirects.php +++ b/src/services/Redirects.php @@ -223,8 +223,6 @@ public function handle404(): void } // Stash the $pathOnly for use when incrementing the statistics $originalPathOnly = $pathOnly; - // Strip out any site-defined baseUrl path prefixes - $pathOnly = UrlHelper::stripSitePathPrefix($pathOnly); // Strip the query string if `alwaysStripQueryString` is set if (Retour::$settings->alwaysStripQueryString) { $fullUrl = UrlHelper::stripQueryString($fullUrl); @@ -241,6 +239,12 @@ public function handle404(): void if (!$this->excludeUri($pathOnly)) { // Redirect if we find a match, otherwise let Craft handle it $redirect = $this->findRedirectMatch($fullUrl, $pathOnly); + // If the redirect wasn't found, look for it without the Site-defined prefix + if ($redirect === null) { + // Strip out any site-defined baseUrl path prefixes + $pathOnly = UrlHelper::stripSitePathPrefix($pathOnly); + $redirect = $this->findRedirectMatch($fullUrl, $pathOnly); + } if (!$this->doRedirect($fullUrl, $pathOnly, $redirect) && !Retour::$settings->alwaysStripQueryString) { // Try it again without the query string $fullUrl = UrlHelper::stripQueryString($fullUrl);