Skip to content

Instantly share code, notes, and snippets.

View oceandiveloper's full-sized avatar

Kevin oceandiveloper

  • Ubud, Bali
View GitHub Profile
@markhowellsmead
markhowellsmead / .htaccess
Last active August 30, 2024 20:04
Detect browser language and redirect to appropriate language version of the website
# Redirect visitors who request 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/
# This has no effect on any subpaths of the website, and therefore has no effect on e.g. WordPress admin.
# Using a 302 temporary redirect header stops the redirection from being cached in the browser.
# language is ES-MX (Mexico)
RewriteCond %{HTTP:Accept-Language} ^es-mx [NC]
RewriteRule ^$ /mx/ [L,R=302]