Last active
July 17, 2020 17:16
-
-
Save markhowellsmead/b2a11764146b8a518e9fb41bc7398107 to your computer and use it in GitHub Desktop.
TYPO3: detect browser language and redirect to appropriate language version of the website if not requesting /typo3/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Redirect visitors to the root domain path (e.g. www.mywebsite.ch) to the appropriate language version | |
# Fallback to English version if no matching browser language defined | |
# Based on language version being at e.g. www.mywebsite.ch/de/ | |
# language starts with DE | |
RewriteCond %{REQUEST_URI} !typo3 | |
RewriteCond %{HTTP:Accept-Language} ^de [NC] | |
RewriteRule ^$ /de/[L,R=301] | |
# language starts with FR | |
RewriteCond %{REQUEST_URI} !typo3 | |
RewriteCond %{HTTP:Accept-Language} ^fr [NC] | |
RewriteRule ^$ /fr/ [L,R=301] | |
# language starts with IT | |
RewriteCond %{REQUEST_URI} !typo3 | |
RewriteCond %{HTTP:Accept-Language} ^it [NC] | |
RewriteRule ^$ /it/ [L,R=301] | |
# else redirect to the English version | |
RewriteCond %{REQUEST_URI} !typo3 | |
RewriteRule ^$ /en/ [L,R=301] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment