Project

General

Profile

Actions

Bug #87455

closed

Redirects for root path on Multi-Language page

Added by Deniz Laun almost 6 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Site Handling, Site Sets & Routing
Target version:
-
Start date:
2019-01-16
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:
On Location Sprint

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

87455.png (239 KB) 87455.png Oliver Hader, 2019-07-25 13:51

Related issues 1 (0 open1 closed)

Is duplicate of TYPO3 Core - Bug #88902: Redirects are not resolved if there is a base path in default siteClosed2019-08-03

Actions
Actions #1

Updated by Deniz Laun almost 6 years ago

I use Typo 9.5.3.
First thought my Bug would be fixed in #86615
It also seems very similiar to #86616

Actions #2

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);
    }
}
Actions #3

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.

Actions #4

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)

Actions #5

Updated by Susanne Moog almost 5 years ago

  • Sprint Focus set to On Location Sprint
Actions #6

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
Actions #7

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.

Actions #8

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',
            ]
        ],
    ]
];

Actions

Also available in: Atom PDF