test appel img twig
This commit is contained in:
@@ -105,8 +105,9 @@ class InitializeProcessor extends ProcessorBase
|
||||
$this->initializeUri($config);
|
||||
|
||||
// Grav may return redirect response right away.
|
||||
if ($config->get('system.pages.redirect_trailing_slash', false)) {
|
||||
$response = $this->handleRedirectRequest($request);
|
||||
$redirectCode = (int)$config->get('system.pages.redirect_trailing_slash', 1);
|
||||
if ($redirectCode) {
|
||||
$response = $this->handleRedirectRequest($request, $redirectCode > 300 ? $redirectCode : null);
|
||||
if ($response) {
|
||||
$this->stopTimer('_init');
|
||||
|
||||
@@ -413,7 +414,7 @@ class InitializeProcessor extends ProcessorBase
|
||||
$this->stopTimer('_init_uri');
|
||||
}
|
||||
|
||||
protected function handleRedirectRequest(RequestInterface $request): ?ResponseInterface
|
||||
protected function handleRedirectRequest(RequestInterface $request, int $code = null): ?ResponseInterface
|
||||
{
|
||||
if (!in_array($request->getMethod(), ['GET', 'HEAD'])) {
|
||||
return null;
|
||||
@@ -426,7 +427,7 @@ class InitializeProcessor extends ProcessorBase
|
||||
|
||||
if ($path !== $root && $path !== $root . '/' && Utils::endsWith($path, '/')) {
|
||||
// Use permanent redirect for SEO reasons.
|
||||
return $this->container->getRedirectResponse((string)$uri->withPath(rtrim($path, '/')), 301);
|
||||
return $this->container->getRedirectResponse((string)$uri->withPath(rtrim($path, '/')), $code);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user