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 September 25, 2024 20:20
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]