Created
July 19, 2016 14:35
-
-
Save thonixx/dc7c84d1c564d1ff8934738bbf0ff87d to your computer and use it in GitHub Desktop.
Language handling with RewriteRules only
This file contains hidden or 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
RewriteEngine on | |
# Language detection (Fallback is en) | |
RewriteCond %{HTTP:Accept-Language} ^de [NC] | |
RewriteCond %{ENV:lang} ^$ | |
RewriteRule ^ - [E=lang:de] | |
RewriteCond %{HTTP:Accept-Language} ^fr [NC] | |
RewriteCond %{ENV:lang} ^$ | |
RewriteRule ^ - [E=lang:fr] | |
RewriteCond %{HTTP:Accept-Language} ^it [NC] | |
RewriteCond %{ENV:lang} ^$ | |
RewriteRule ^ - [E=lang:it] | |
RewriteCond %{HTTP:Accept-Language} ^en [NC,OR] | |
RewriteCond %{ENV:lang} ^$ | |
RewriteRule ^ - [E=lang:en] | |
# now the example with a rewriterule | |
RewriteRule ^/?$ https://%{HTTP_HOST}/index.html#lang=%{ENV:lang} [L,R=301,NE] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment