#88544Trailing slash gets added to "homepage" urls if base is without trailing slash
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.
Related issues 3
History 6
-
Richard Haeser commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2019-08-21T20:16:58+00:00" > 08/21/19, 20:16 </span> -
Kevin Appelt commented and changed subject
Trailing slash while using canoinical URLTrailing slash gets added to "homepage" urls if base is without trailing slash category statusNeeds FeedbackAccepted priorityShould haveMust 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/env10 (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/enEspecially for the canonicals this 307 redirect is very unfortunate.
Conclusion- This problem is within the url generation of TYPO3 and not only related to the canonical.
- This problem is not related to a special TYPO3 or PHP Version.
- 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 correctDomain | 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/subpagehttps://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/subpageEnforced Trailing Slash for all urls via custom RouteEnhancer only
Trailing slash without enforcement should redirect via 307 to no trailing slash -
Guido Schmechel changed Related to #90045 <span data-processor="relativetime" data-value="2020-01-19T00:20:37+00:00" > 01/19/20, 00:20 </span>
-
Timo Poppinga changed Related to #90151 <span data-processor="relativetime" data-value="2020-01-19T20:50:51+00:00" > 01/19/20, 20:50 </span>
-
Sybille Peters changed Related to #89091 <span data-processor="relativetime" data-value="2020-12-07T14:20:46+00:00" > 12/07/20, 14:20 </span>
-
Georg Ringer commented and changed status
AcceptedClosed <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 thehreflangalternates 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, allhreflangalternates (includingx-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!
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?