Stefan Müller
Stefan Müller

Reputation: 323

TYPO3 11.5 - redirect to urls with trailing slash or not

I noticed that TYPO3 11.5 results in a 404 error when the trailing slash is omitted. In older TYPO3 versions a simple rule in .htaccess could redirect to URLs with trailing slash instead. When I apply this rule (TYPO3 - force trailing-slashes) to version 11.5 the backend would do endless redirects (as it is without trailing slash)

What would be best practice for TYPO3 11.5 ? Should we redirect at all ?

Upvotes: 1

Views: 625

Answers (1)

Stefan Müller
Stefan Müller

Reputation: 323

For the moment, this part in .htaccess seem to solve the issue for me:

# add trailing slash for outside typo3 folder if missing
RewriteCond %{REQUEST_URI} !^/(typo3)/ [NC]
RewriteRule ^([^\.]*[^/])$ http://%{HTTP_HOST}/$1/ [L,R=301]

I put this part near the end of all default-mod-rewirte code before this default-part:

# If the file/symlink/directory does not exist => Redirect to index.php.
# For httpd.conf, you need to prefix each '%{REQUEST_FILENAME}' with '%{DOCUMENT_ROOT}'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^.*$ %{ENV:CWD}index.php [QSA,L]

Upvotes: 1

Related Questions