Issue Bug Closed

#90151ContentObjectRenderer typoLink language link is generated witch /

Timo Poppinga 01/19/20, 18:24 updated 11/14/26, 19:34

Description

If you use the method typoLink of the class ContentObjectRenderer to generate an link of an root language page like /en or /de. It comse alle the time wich / at the end e.g. /en/ /de/.

If you configure in your site config e.g.

-
title: Englisch
enabled: true
base: /en
typo3Language: default
locale: en_GB.UTF-8
iso-639-1: en
websiteTitle: ‘‘
navigationTitle: English
hreflang: en-GB
direction: ltr
fallbackType: strict
fallbacks: ‘‘
flag: en-us-gb
languageId: ‘3’

you can call the site by /de and /de/ will be redirected to /de but the typoLink method still genarte an link /de/

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 13

  1. Timo Poppinga commented <span data-processor="relativetime" data-value="2020-01-19T18:37:00+00:00" > 01/19/20, 18:37 </span>

    Issue must be in PageLinkBuilder->build

    Add an dirty hack in the file of

    \TYPO3\CMS\Core\Routing\PageRouter

    at line 327 like:

    $path = $uri->getPath();
    if(strlen($path) === 4) {
    $uri = $uri->withPath(substr($path, 0, 3));
    }

    helps. But it is really dirty!

  2. Benni Mack commented <span data-processor="relativetime" data-value="2020-01-20T08:42:45+00:00" > 01/20/20, 08:42 </span>

    It’s currently a limitation of Site Handling:

    The site root page has the slug “/” (because it needs to contain a slug), that’s why all links to this page have a trailing slash.

  3. Timo Poppinga commented <span data-processor="relativetime" data-value="2020-01-20T11:55:13+00:00" > 01/20/20, 11:55 </span>

    hi Benni, thx for replaying.

    Is there an speciel reasen wey it is not suppport yet? For my point of view site config, rendering, access view /de as well redirecting from /de/ works fine. Only the link generation do not work propper.

    Or do i overlooked somethink?

    Is it more an Symphony or TYPO3 Routing toppic?

  4. sven waechli commented and changed TYPO3 Version 10 11 <span data-processor="relativetime" data-value="2023-07-13T08:26:55+00:00" > 07/13/23, 08:26 </span>

    We still encounter the problem, which is quite a nasty one for multilanguage sites, on TYPO3 11 LTS. (haven’t checked V12 yet)

  5. Marcin Sągol commented <span data-processor="relativetime" data-value="2025-02-21T11:33:36+00:00" > 02/21/25, 11:33 </span>

    This “issue” still exists (v12), and as a workaround we are using https://packagist.org/packages/b13/de-slash with a custom event listener to handle also URL-s with query parameters.

  6. Georg Ringer commented and changed status New Closed <span data-processor="relativetime" data-value="2026-11-14T19:34:32+00:00" > 11/14/26, 19:34 </span>

    Hi, and thanks for reporting this and for the detailed description!

    I could reproduce the behaviour on main. It is caused by the language base without a trailing slash: with base: /de the link to the language root page (slug /) is generated as /de/, while a request to /de/ is redirected (307) back to /de.

    The two spellings of the base behave like this:

    Language base Request /de Request /de/ Generated link to root page
    /de/ 200 200 /de/
    /de 200 307 to /de /de/

    Link generation always ends up with the trailing slash for the root page, because the slug of the root page is /. Pages below the root are not affected (/de/subpage in both cases). Whether the site base itself ends with a slash does not matter.

    The recommended way to avoid the redirect is to configure the language base with a trailing slash (base: /de/). Then generated links, canonical URLs and the sitemap match the URL that is delivered, and no redirect happens.

    Changing the link generation for bases without trailing slash would alter the URLs of every existing site that uses this spelling (canonicals, sitemaps, redirects, caches), so I am closing this as works as designed.

    If this is still valid for you in v14, please open a new issue and provide information how to reproduce it. Thanks!