1) { # Split possible languages into array $x = explode(",",$http_accept); foreach ($x as $val) { #check for q-value and create associative array. No q-value means 1 by rule if(preg_match("/(.*);q=([0-1]{0,1}\.\d{0,4})/i",$val,$matches)) $lang[$matches[1]] = (float)$matches[2]; else $lang[$val] = 1.0; } #return default language (highest q-value) $qval = 0.0; foreach ($lang as $key => $value) { if ($value > $qval) { $qval = (float)$value; $deflang = $key; } } } return strtolower($deflang); } $lang = substr(getDefaultLanguage(), 0, 2); if ($lang == "en") { header("Status: 301 Moved Permanently", false, 301); header("Location: https://www.terralgo.com/en/"); exit; } else if ($lang == "es") { header("Status: 301 Moved Permanently", false, 301); header("Location: https://www.terralgo.com/es/"); exit; } else if ($lang == "fr") { header("Status: 301 Moved Permanently", false, 301); header("Location: https://www.terralgo.com/fr/"); exit; } else if ($lang == "de") { header("Status: 301 Moved Permanently", false, 301); header("Location: https://www.terralgo.com/de/"); exit; } else { header("Status: 301 Moved Permanently", false, 301); header("Location: https://www.terralgo.com/en/"); exit; } ?>