Last active
July 25, 2021 17:25
-
-
Save varnav/782d5aeb42c6ffa77678025767013c95 to your computer and use it in GitHub Desktop.
Nginx can redirect to language subsite based on browser language
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
map $http_accept_language $index_redirect_uri { | |
default "/en/"; | |
"~(^|,)en.+,ru" "/en/"; | |
"~(^|,)ru.+,en" "/ru/"; | |
"~(^|,)en" "/en/"; | |
"~(^|,)ru" "/ru/"; | |
} | |
location = / { | |
return 302 $index_redirect_uri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment