Skip to content

Commit

Permalink
Fixed site redirect with redirect code failing when redirecting to su…
Browse files Browse the repository at this point in the history
…b-pages [#3035]
  • Loading branch information
mahagr committed Mar 11, 2021
1 parent 6dd7044 commit a67a538
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions system/src/Grav/Common/Grav.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ public function getRedirectResponse($route, $code = null): ResponseInterface
}

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]);
Expand Down

0 comments on commit a67a538

Please sign in to comment.