Skip to content

Commit

Permalink
refactor: Only look for the redirect with a stripped path prefix if i…
Browse files Browse the repository at this point in the history
…t wasn’t found with the prefix
  • Loading branch information
khalwat committed Sep 13, 2024
1 parent 1a955cd commit 153482c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/services/Redirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 153482c

Please sign in to comment.