Fixed trailing slash redirect to use 301 status code [#3127]

This commit is contained in:
Matias Griese
2021-02-09 21:36:54 +02:00
parent 5a9477a402
commit 87a01bbe0a
2 changed files with 3 additions and 2 deletions

View File

@@ -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

View File

@@ -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;