From a67a538dfdeda51cd4cc5e92e4340438e2d188ad Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Thu, 11 Mar 2021 18:39:18 +0200 Subject: [PATCH] Fixed site redirect with redirect code failing when redirecting to sub-pages [#3035] --- CHANGELOG.md | 1 + system/src/Grav/Common/Grav.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 712ba70fb..ca5b8a473 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ * Fixed Markdown image attribute `loading` [#3251](https://github.com/getgrav/grav/pull/3251) * Fixed `Uri::isValidExtension()` returning false positives * Fixed `page.html` returning duplicated content with `system.pages.redirect_default_route` turned on [#3130](https://github.com/getgrav/grav/issues/3130) + * Fixed site redirect with redirect code failing when redirecting to sub-pages [#3035](https://github.com/getgrav/grav/pull/3035/files) # v1.7.7 ## 02/23/2021 diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index 1448113ae..d9ad28957 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -431,8 +431,8 @@ class Grav extends Container } if (null === $code) { - // Check for code in route - $regex = '/.*(\[(30[1-7])\])$/'; + // Check for redirect code in the route: e.g. /new/[301], /new[301]/route or /new[301].html + $regex = '/.*(\[(30[1-7])\])(.\w+|\/.*?)?$/'; preg_match($regex, $route, $matches); if ($matches) { $route = str_replace($matches[1], '', $matches[0]);