Skip to content

Instantly share code, notes, and snippets.

@sftsk
Created November 8, 2016 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sftsk/5a0f1f6df7c5202e7fb487a09be8787a to your computer and use it in GitHub Desktop.
Save sftsk/5a0f1f6df7c5202e7fb487a09be8787a to your computer and use it in GitHub Desktop.
Browser language based forward .htaccess
# redirect first visitors basing on their language or redirect if language not specified
# in URL. If italian, redirect to italian
# if lang is Italian use it
RewriteCond %{THE_REQUEST} !\s/(de|it|app|wp)/ [NC]
RewriteCond %{HTTP:Accept-Language} ^it [NC]
RewriteRule ^ /it%{REQUEST_URI} [L,NC,R=301]
# otherwise use German
RewriteCond %{THE_REQUEST} !\s/(de|it|app|wp)/ [NC]
RewriteRule ^ /de%{REQUEST_URI} [L,NC,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment