<?php
// languages list
$sites = array(
"en" => "http://en.site.com/",
"es" => "http://au.site.com/",
"fr" => "http://ru.site.com/",
);
// get language
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
// check language
if (!in_array($lang, array_keys($sites))){
$lang = 'en';
}
// redirect to a subdomain
header('Location: ' . $sites[$lang]);
?>
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.