From 4be9503d2cca390ba59e8031494c1a8540a4ff6e Mon Sep 17 00:00:00 2001 From: Nathan Glasl Date: Mon, 6 Jun 2016 12:49:18 +1000 Subject: [PATCH] Correcting an issue when resolving the home page URL, namely when a "home" page existed under other pages. --- README.md | 2 +- code/requestfilters/MisdirectionRequestFilter.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 33f9a30..cf22cc6 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.5**_ +_The current release is **2.2.6**_ > 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/requestfilters/MisdirectionRequestFilter.php b/code/requestfilters/MisdirectionRequestFilter.php index 0d85a3e..0ed7725 100644 --- a/code/requestfilters/MisdirectionRequestFilter.php +++ b/code/requestfilters/MisdirectionRequestFilter.php @@ -99,8 +99,9 @@ public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, // Determine the home page URL when replacing the default automated URL handling. $link = $map->getLink(); - if($replace && (strpos(strrev(trim($link, '/')), strrev('home')) === 0)) { - $link = Director::baseURL(); + $base = Director::baseURL(); + if($replace && (substr($link, 0, strlen($base)) === $base) && (substr($link, strlen($base)) === 'home/')) { + $link = $base; } // Update the response using the link mapping redirection.