diff --git a/CHANGELOG.md b/CHANGELOG.md index c46c090fc..efbe64f68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ * Fixed renaming flex objects key when using file storage * Fixed wrong values in Admin pages list [#3214](https://github.com/getgrav/grav/issues/3214) * Fixed pipelined asset using different hash when extra asset is added to before/after position [#2781](https://github.com/getgrav/grav/issues/2781) - * Only redirect GET/HEAD if `system.pages.redirect_trailing_slash` is true and request has a trailing slash + * Fixed trailing slash redirect to only apply to GET/HEAD requests and use 301 status code [#3127](https://github.com/getgrav/grav/issues/3127) # v1.7.5 ## 02/01/2021 diff --git a/system/src/Grav/Common/Processors/InitializeProcessor.php b/system/src/Grav/Common/Processors/InitializeProcessor.php index 924dc29ca..a6a606cc6 100644 --- a/system/src/Grav/Common/Processors/InitializeProcessor.php +++ b/system/src/Grav/Common/Processors/InitializeProcessor.php @@ -425,7 +425,8 @@ class InitializeProcessor extends ProcessorBase $root = $this->container['uri']->rootUrl(); if ($path !== $root && $path !== $root . '/' && Utils::endsWith($path, '/')) { - return $this->container->getRedirectResponse((string)$uri->withPath(rtrim($path, '/'))); + // Use permanent redirect for SEO reasons. + return $this->container->getRedirectResponse((string)$uri->withPath(rtrim($path, '/')), 301); } return null;