mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1515 from dhensby/pulls/3.2/fix-infinite-404-redirect
Prevent OldPageRedirector looping infinitely
This commit is contained in:
commit
aca12d1de5
@ -12,13 +12,18 @@ class OldPageRedirector extends Extension {
|
||||
public function onBeforeHTTPError404($request) {
|
||||
// We need to get the URL ourselves because $request->allParams() only has a max of 4 params
|
||||
$params = preg_split('|/+|', $request->getURL());
|
||||
$cleanURL = trim(Director::makeRelative($request->getURL(false), '/'));
|
||||
|
||||
$getvars = $request->getVars();
|
||||
unset($getvars['url']);
|
||||
|
||||
$page = self::find_old_page($params);
|
||||
$cleanPage = trim(Director::makeRelative($page), '/');
|
||||
if (!$cleanPage) {
|
||||
$cleanPage = Director::makeRelative(RootURLController::get_homepage_link());
|
||||
}
|
||||
|
||||
if ($page) {
|
||||
if ($page && $cleanPage != $cleanURL) {
|
||||
$res = new SS_HTTPResponse();
|
||||
$res->redirect(
|
||||
Controller::join_links(
|
||||
|
Loading…
Reference in New Issue
Block a user