Created
July 10, 2020 13:18
-
-
Save peaceman/2b0a11d8d7c5fde766d6249976980cef to your computer and use it in GitHub Desktop.
nginx locale redirect
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
# locale redirect | |
if ($http_accept_language ~* "^en") { | |
set $locale_specific_subdomain "en"; | |
} | |
if ($http_accept_language ~* "^fr") { | |
set $locale_specific_subdomain "fr"; | |
} | |
if ($http_accept_language ~* "^da") { | |
set $locale_specific_subdomain "dk"; | |
} | |
if ($http_accept_language ~* "^it") { | |
set $locale_specific_subdomain "it"; | |
} | |
if ($http_accept_language ~* "^es") { | |
set $locale_specific_subdomain "es"; | |
} | |
if ($http_accept_language ~* "^nl") { | |
set $locale_specific_subdomain "nl"; | |
} | |
location = / { | |
add_header Vary "Accept-Language"; | |
error_page 461 = @shopware; // as default | |
if ($http_accept_language ~* "^de") { | |
return 461; | |
} | |
return 303 https://$locale_specific_subdomain.example.com; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment