Issue Bug Closed

#88544Trailing slash gets added to "homepage" urls if base is without trailing slash

Altan Tosun 06/12/19, 11:43 updated 11/14/26, 19:57

Description

While using language prefixes within the URL like /de, the canonical URL is always ending with a trailing slash (/de/)

TYPO3 version: 9.5.7

Reviews 0

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

History 6

  1. Richard Haeser commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2019-08-21T20:16:58+00:00" > 08/21/19, 20:16 </span>

    Atlan,

    The canonical link is created like all other links, so I guess all links have a trailing slash in your situation? Can you give me some more background information of your case?

  2. Kevin Appelt commented and changed subject Trailing slash while using canoinical URL Trailing slash gets added to "homepage" urls if base is without trailing slash category status Needs Feedback Accepted priority Should have Must have <span data-processor="relativetime" data-value="2019-10-25T13:00:52+00:00" > 10/25/19, 13:00 </span>

    I can confirm the issue.

    v9 /en/
    <link rel="canonical" href="https://typo3-9.ddev.site/en/">

    v9 /en
    <link rel="canonical" href="https://typo3-9.ddev.site/en/"> => which resolves to a 307 to https://typo3-9.ddev.site/en

    v10 (current master) /en/
    <link rel="canonical" href="https://typo3-master.ddev.site/en/">

    v10 (current master) /en
    <link rel="canonical" href="https://typo3-master.ddev.site/en/"> => which resolves to a 307 to https://typo3-master.ddev.site/en

    Especially for the canonicals this 307 redirect is very unfortunate.

    Conclusion
    1. This problem is within the url generation of TYPO3 and not only related to the canonical.
    2. This problem is not related to a special TYPO3 or PHP Version.
    3. This problem is only related to the “homepage” of a site, but not to subpages.

    *Suggestions*
    https://example.org/ <— (root resource, ending with slash)
    https://example.org/en/whatever <— correct
    https://example.org/en/whatever/ <— not correct

    Domain | Site Language Base | Slug
    https://example.org | /en | / —> https://example.org/en
    https://example.org | /en/ | / —> https://example.org/en
    https://example.org | / | / —> https://example.org/

    https://example.org | /en | /subpage —> https://example.org/en/subpage
    https://example.org | /en/ | /subpage —> https://example.org/en/subpage
    https://example.org | / | /subpage —> https://example.org/subpage

    https://example.org | /en | /subpage/ —> https://example.org/en/subpage
    https://example.org | /en/ | /subpage/ —> https://example.org/en/subpage
    https://example.org | / | /subpage/ —> https://example.org/subpage

    Enforced Trailing Slash for all urls via custom RouteEnhancer only
    Trailing slash without enforcement should redirect via 307 to no trailing slash

  3. Georg Ringer commented and changed status Accepted Closed <span data-processor="relativetime" data-value="2026-11-14T19:57:53+00:00" > 11/14/26, 19:57 </span>

    Hi, and thanks for reporting this and for the detailed analysis, also to everyone who added details later!

    This is the same behaviour as described in #90151: with a language base without a trailing slash (base: /en), the link to the language root page (slug /) is generated as /en/, while a request to /en/ is redirected (307) back to /en. As the canonical URL and the hreflang alternates are built with the same link generation, they point to the redirecting URL as well.

    The recommended setup is to configure the language base with a trailing slash (base: /en/). I verified this on main with two languages: canonical, all hreflang alternates (including x-default) and the delivered URL match, 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 this is working as designed.

    I am closing this as a duplicate of #90151, where the details are documented. Thanks!