<?php
if (mobile_detect())
{
header("Location: http://m.your_site.com/" src="/content/reactions/bystrie/podmig-original.png" alt="*" />; // переадресация на "мобильную весию" сайта
}
else
{
header("Location: http://your_site.com/" src="/content/reactions/bystrie/podmig-original.png" alt="*" />;
}
?>
Думаю многим будут полезний!
// Для определения мобильных устройств можно использовать следующую функцию
function mobile_detect()
{
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$ipod = strpos($user_agent,"iPod");
$iphone = strpos($user_agent,"iPhone");
$android = strpos($user_agent,"Android");
$symb = strpos($user_agent,"Symbian");
$winphone = strpos($user_agent,"WindowsPhone");
$wp7 = strpos($user_agent,"WP7");
$wp8 = strpos($user_agent,"WP8");
$operam = strpos($user_agent,"Opera M");
$palm = strpos($user_agent,"webOS");
$berry = strpos($user_agent,"BlackBerry");
$mobile = strpos($user_agent,"Mobile");
$htc = strpos($user_agent,"HTC_");
$fennec = strpos($user_agent,"Fennec/");
if ($ipod || $iphone || $android || $symb || $winphone || $wp7 || $wp8 || $operam || $palm || $berry || $mobile || $htc || $fennec)
{
return true;
}
else
{
return false;
}
}