From 64f16e5ca3c1afd963db91b24ae36f44d51d867b Mon Sep 17 00:00:00 2001 From: Nathan Glasl Date: Mon, 6 Jun 2016 15:02:24 +1000 Subject: [PATCH] Correcting an issue where fallback URLs were not being resolved as expected. --- code/services/MisdirectionService.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/code/services/MisdirectionService.php b/code/services/MisdirectionService.php index f5a5c07..3b046d9 100644 --- a/code/services/MisdirectionService.php +++ b/code/services/MisdirectionService.php @@ -292,19 +292,25 @@ public function determineFallback($URL) { if($applicableRule) { $link = null; switch($applicableRule) { + + // Bypass the request filter. + case 'Nearest': - $link = $nearestParent; + $link = '/' . HTTP::setGetVar('misdirected', true, $nearestParent); break; case 'This': - $link = $thisPage; + $link = '/' . HTTP::setGetVar('misdirected', true, $thisPage); break; case 'URL': - $link = self::is_external_URL($toURL) ? (ClassInfo::exists('Multisites') ? HTTP::setGetVar('misdirected', true, $toURL) : $toURL) : Controller::join_links(Director::baseURL(), $toURL); + + // When appropriate, prepend the base URL to match a page redirection. + + $link = self::is_external_URL($toURL) ? (ClassInfo::exists('Multisites') ? HTTP::setGetVar('misdirected', true, $toURL) : $toURL) : ('/' . HTTP::setGetVar('misdirected', true, Controller::join_links(Director::baseURL(), $toURL))); break; } if($link) { return array( - 'link' => self::is_external_URL($link) ? $link : ('/' . HTTP::setGetVar('misdirected', true, $link)), + 'link' => $link, 'code' => (int)$responseCode ); }