Bug #87455
closedRedirects for root path on Multi-Language page
0%
Description
I have a multi-lang page configuration with two languages, /de & /en paths.
If I create redirects in the module, I can only create working redirects that match the language.
So /de/test or /en/test.
A non-language-path redirect like /test is redirected directly to the default language - in my case /de.
rootPageId: 1
base: 'https://example.net/'
languages:
-
title: Deutsch
enabled: true
languageId: '0'
base: /de
typo3Language: de
locale: de_DE.utf-8
iso-639-1: de
navigationTitle: Deutsch
hreflang: de-DE
direction: ltr
flag: de
-
title: Englisch
enabled: true
languageId: '1'
base: /en
typo3Language: default
locale: en_US.utf-8
iso-639-1: en
navigationTitle: English
hreflang: en-US
direction: ltr
fallbackType: fallback
flag: en-us-gb
errorHandling: { }
baseVariants: { }
routes:
-
route: robots.txt
type: staticText
content: "User-agent: *\r\nDisallow: /typo3/\r\nDisallow: /typo3_src/\r\nAllow: /typo3/sysext/frontend/Resources/Public/*\r\n"
Files
Updated by Deniz Laun almost 6 years ago
Updated by Remo H. over 5 years ago
Same problem here. Changing the order of the middlewares is a possible solution...
return [
'frontend' => [
'typo3/cms-redirects/redirecthandler' => [
'disabled' => true,
],
'hotfix-redirecthandler' => [
'target' => \TYPO3\CMS\Redirects\Http\Middleware\RedirectHandler::class,
'before' => [
'typo3/cms-frontend/base-redirect-resolver',
],
],
],
];
Other solution, add a middleware before "typo3/cms-frontend/base-redirect-resolver"
class SetDefaultLanguage implements MiddlewareInterface
{
/**
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
* @return ResponseInterface
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$site = $request->getAttribute('site', null);
$language = $request->getAttribute('language', null);
if ($site instanceof Site && !($language instanceof SiteLanguage)) {
$language = $site->getDefaultLanguage();
$request = $request->withAttribute('language', $language);
}
return $handler->handle($request);
}
}
Updated by Johannes Seipelt over 5 years ago
experienced the same issue on 9.5.8
the workaround with the added middleware did not work for me.
Updated by Oliver Hader over 5 years ago
typo3/cms-redirects/redirecthandler
should be handled before typo3/cms-frontend/base-redirect-resolver
which does not seem to be the case currently (9.5.9-dev)
Updated by Susanne Moog almost 5 years ago
- Sprint Focus set to On Location Sprint
Updated by Daniel Goerz almost 5 years ago
- Is duplicate of Bug #88902: Redirects are not resolved if there is a base path in default site added
Updated by Daniel Goerz almost 5 years ago
- Status changed from New to Closed
Hi,
you are running into the issue of redirect middleware ordering because your (valid) setup does not provide any language entry points for '/'.
The core currently ships the base-redirect-resolver before the redirect-handler (ext:redirects) by default.
This has been addressed with #88902 in v10 where a feature switch exist to switch the order of the two redirecting middlewares.
In v11 we will change the default order and will remove the feature switch again (which is a breaking change).
In v9 you have to change the order of the two middlewares yourself as mentioned above. You can also refer to the documentation for switching order of middlewares: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/RequestHandling/Index.html#override-ordering-of-middlewares
I am closing the issue here because there will be no change to the ordering of the middlewares in v9 because we cannot have any breaking changes in a LTS version.
Updated by Markus Mächler over 4 years ago
For TYPO3 9 we used the following middleware reordering to workaround this issue for redirects and also static routes:
typo3conf/ext/your_ext/Configuration/RequestMiddlewares.php
<?php
return [
'frontend' => [
'typo3/cms-frontend/base-redirect-resolver' => [
'before' => [
'typo3/cms-frontend/page-resolver',
],
'after' => [
'typo3/cms-redirects/redirecthandler',
],
],
'typo3/cms-redirects/redirecthandler' => [
'before' => [
'typo3/cms-frontend/base-redirect-resolver',
],
'after' => [
'typo3/cms-frontend/tsfe',
'typo3/cms-frontend/authentication',
'typo3/cms-frontend/static-route-resolver',
],
],
'typo3/cms-frontend/static-route-resolver' => [
'before' => [
'typo3/cms-frontend/base-redirect-resolver',
'typo3/cms-frontend/page-resolver',
],
'after' => [
'typo3/cms-frontend/authentication',
]
],
]
];