when website open in mobile redirect to subdomain

when website open in mobile redirect to subdomain

$_SERVER – Server and execution environment information


My Android browser Output:

Mozilla/5.0 (Linux; U; Android 2.1-update1; en-in; HTC_Wildfire_A3333 Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari

Usining strpos() function find position of first occurrence of a string.


$iphone = strpos($_SERVER[‘HTTP_USER_AGENT’],”iPhone“);
$android = strpos($_SERVER[‘HTTP_USER_AGENT’],”Android“);
$palmpre = strpos($_SERVER[‘HTTP_USER_AGENT’],”webOS“);
$berry = strpos($_SERVER[‘HTTP_USER_AGENT’],”BlackBerry“);
$ipod = strpos($_SERVER[‘HTTP_USER_AGENT’],”iPod“);

if ($iphone || $android || $palmpre || $ipod || $berry == true)
header(‘Location: http://mobile.site.com/’);


Index.php or Home.php
You have to include like following script.


include(‘user_agent.php’); // Redirecting http://mobile.site.info
// site.com data

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

hirebee wordpress theme nulled

Next Post


Related Posts