0

In ddev / TYPO3 / .htaccess - redirect all http -> https Krystian Szymukowicz already gave the solution on how to redirect all http to https in ddev, thx a lot once more!

Now I face the problem of trailing slash and non-trailing slash.

In the TYPO3 site config.yaml I have set

routeEnhancers:
  PageTypeSuffix:
    type: PageType
    default: /
    index: ''
    map:
      /: 0

That works fine and TYPO3 creates the URLs always with a trailing slash eg. in menus or when linking in the TYPO3 backend. But the pages are also accessible without the trailing slashes which I'm afraid of duplicate content interpretation.

how can I force the trailing slash if someone calls the url without trailing slash? eg. by entering the url manually https://domain.tld/some-site

Peter Kraume
  • 3,577
  • 2
  • 21
  • 39
skyfreak42
  • 55
  • 1
  • 8

1 Answers1

4

That can be solved via a .htaccess rule:

RewriteRule ^([^\.]*[^/])$ https://%{HTTP_HOST}/$1/ [L,R=301]

If you have mixed content (http/https), you need to further adapt the RewriteRule.

Peter Kraume
  • 3,577
  • 2
  • 21
  • 39
  • Thank you for your quick reply, the code snippet workz perfect! And NO, I don not have mixed content, all HTTPS, but thank you for the annotation. – skyfreak42 Jan 18 '21 at 17:12
  • This works for me too, but unfortunately it also breaks my tx_seo XmlSitemap. The Links generated by the XmlSitemapRenderer contain no pageType - there seems to have been a issue in the bugtracker, set to 100% but that problem seems to have resurfaced: https://forge.typo3.org/issues/87817 Any ideas on how to work around that problem? – j4k3 Feb 16 '21 at 18:52