Skip to content

Instantly share code, notes, and snippets.

@hutt
Created November 10, 2012 21:25
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 hutt/4052560 to your computer and use it in GitHub Desktop.
Save hutt/4052560 to your computer and use it in GitHub Desktop.
Redirect other-speaking visitors to other directories/websites.
<?php
if(!isset($_COOKIE['lang'])){
$lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2);
switch($lang) {
case 'de':
$redirect = '/de';break;
case 'en':
$redirect = '/en';break;
default:
$redirect = '/en'; }
header ("location: $redirect");
setcookie("lang", "de");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment