diff --git a/README.md b/README.md index 618d36f..329ca71 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [misdirection](https://packagist.org/packages/nglasl/silverstripe-misdirection) -_The current release is **2.2.24**_ +_The current release is **2.2.25**_ > A module for SilverStripe which will allow both simple and regular expression link redirections based on customisable mappings, either hooking into a page not found or replacing the default automated URL handling. diff --git a/code/dataobjects/LinkMapping.php b/code/dataobjects/LinkMapping.php index 4c9056a..ab7ca36 100644 --- a/code/dataobjects/LinkMapping.php +++ b/code/dataobjects/LinkMapping.php @@ -350,7 +350,19 @@ public function getLink() { // When appropriate, prepend the base URL to match a page redirection. - return MisdirectionService::is_external_URL($link) ? (ClassInfo::exists('Multisites') ? HTTP::setGetVar('misdirected', true, $link) : $link) : Controller::join_links(Director::baseURL(), $link); + $prepended = Controller::join_links(Director::baseURL(), $link); + if(MisdirectionService::is_external_URL($link)) { + return ClassInfo::exists('Multisites') ? HTTP::setGetVar('misdirected', true, $link) : $link; + } + + // This is needed, otherwise infinitely recursive mappings won't be detected in advance. + + else if(MisdirectionService::is_external_URL($prepended)) { + return $link; + } + else { + return $prepended; + } } }