diff --git a/code/dataobjects/LinkMapping.php b/code/dataobjects/LinkMapping.php index 792e738..cdea46e 100644 --- a/code/dataobjects/LinkMapping.php +++ b/code/dataobjects/LinkMapping.php @@ -333,7 +333,7 @@ public function getLink() { // This is to support multiple sites, where the absolute page URLs are treated as relative. - return MisdirectionService::is_external_URL($link) ? HTTP::setGetVar('misdirected', true, ltrim($link, '/')) : $link; + return MisdirectionService::is_external_URL($link) ? ltrim($link, '/') : $link; } } else { diff --git a/code/services/MisdirectionService.php b/code/services/MisdirectionService.php index 91f706b..fb31a5a 100644 --- a/code/services/MisdirectionService.php +++ b/code/services/MisdirectionService.php @@ -176,9 +176,9 @@ public function getRecursiveMapping($map, $host = null, $testing = false) { $host = $map->getLinkHost(); } - // Determine the next link mapping. + // Determine the next link mapping, immediately redirecting towards an external URL. - while(!self::is_external_URL($redirect) && ($next = $this->getMapping($redirect, $host))) { + while((($map->RedirectType === 'Page') || !self::is_external_URL($redirect)) && ($next = $this->getMapping($redirect, $host))) { // Enforce a maximum number of redirects, preventing infinite recursion and inefficient link mappings.