I have a Typo3 11.5 website with the default language German (example.com/de/) and the second language English (example.com/en/). If only the base url (example.com) is called, it is automatically redirected to the default language. I would now like to change this redirection to the secondary language.
This is my current config.yml
base: /
languages:
-
title: Deutsch
enabled: true
languageId: 0
base: /de/
typo3Language: de
locale: de_DE.utf8
iso-639-1: de
navigationTitle: Deutsch
hreflang: de
direction: ltr
flag: de
-
title: Englisch
enabled: true
languageId: 1
base: /en/
typo3Language: default
locale: en_US.utf8
iso-639-1: en
navigationTitle: English
hreflang: en
direction: ltr
fallbackType: strict
fallbacks: ''
flag: en-us-gb
By swapping the order of the languages, the correct forwarding to example.com/en works directly, but the backend language behavior is also changed so that only the English language can be edited.
I have already tried the following redirect:
RewriteRule !^(en|de)/ https://example.de/en [R=307,L]
However, this leads to an endless redirect.
This redirect in .htaccess should do what you want:
RewriteRule ^$ https://%{HTTP_HOST}/en [R=301,L]
^$ means no path. Redirects https://example.com to https://example.com/en