PDA

View Full Version : Simple script to sort traffic by browser language


Yahook
08-07-2005, 09:27 PM
<?
//here DE i ne EN
$all="http://www.url1.com/";

//here DE
$de="http://www.url2.com/";

//here EN
$en="http://www.url3.com/";

$redirekt=$all;
$language=strtolower(substr($HTTP_ACCEPT_LANGUAGE, 0,2));
if($language=="de")$redirekt=$de;
if($language=="en")$redirekt=$en;
header("location:$redirekt");exit;
?>

xariton
08-10-2005, 06:09 AM
Here is the same script but for GEOIP
Just put country code=>url to redirect in array
<?
$gips=array(
"DE"=>"http://www.de.com",
"EN"=>"http://www.en.com",
"US"=>"http://www.us.com",
);

$url="http://www.any.com";

$gcc = getenv("GEOIP_COUNTRY_CODE");

if(in_array ($gcc, array_keys($gips))){
$url=$gips[$gcc];
}

header("Location:$url");
exit;
?>