Search code examples
typo3typo3-9.x

How can I add a trailing slash to TYPO3 v9 URLs?


When updating from TYPO3 8.7 to TYPO3 9.5 you might drop the realurl extension in favor for the new routing feature.

But you might notice, that realurl appended a / to all urls by default (when you are not using html suffix) The TYPO3 routing feature does not do that by default and there is currently no option in the core to enable this. Why is this a problem? In TYPO3 8.7 you got an URL like www.domain.tld/subpage/. In TYPO3 9.5 the same page be called with the url www.domain.tld/subpage. So even if this is the same page, for search crawlers, this is another URL. TYPO3 does a 307 redirect when calling the URL with an appending /, but you might want to use your old URL structure.

How can I configure TYPO3 to add a trailing "/"?


Solution

  • You can use the PageTypeEnhancer for mapping &type parameter in your site configuration (config.yaml file):

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