View Full Version : Mobile site

09-20-2011, 10:09 AM
Ive been asked to make someone a mobile version of there site, its a totally new layout so i want to put it on a subdomain, how would i tell the browser to redirect there? Is there a simple line or two i can put saying if mobile device redirect to xxxx or would it be a javascript redirect?

09-20-2011, 01:27 PM
Hosting providers have no obligation to help you with this. It's a purely development issue. They probably wont help you with it.

http://code.google.com/p/php-mobile-detect/ - try that. I haven't used it myself, but if it works, it will be good :). Using that, I'm guessing you would just write at the top of the pages you want:

if ($detect->isMobile()) {
// any mobile platform
header("location: http://mobile.yoursite.com/");

09-20-2011, 01:39 PM
Ahh thanks, ill take a look at that :).

I did find this

/* detect mobile device*/
$ismobile = 0;
$container = $_SERVER['HTTP_USER_AGENT'];

// A list of mobile devices
$useragents = array (

'Blazer' ,
'Palm' ,
'Handspring' ,
'Nokia' ,
'Samsung' ,
'Motorola' ,
'Windows CE' ,
'Blackberry' ,
'WAP' ,
'PlayStation Portable',


foreach ( $useragents as $useragents ) {
if(strstr($container,$useragents)) {
$ismobile = 1;

if ( $ismobile == 1 ) {
echo "<p>mobile device</p>";


However that foreach loop looks like it couldnt be done a bit better, maybe in_array somehow. If the google code doesnt work (although i cant see anything google post not working) ill try that i found.

09-20-2011, 02:06 PM
if (in_array($_SERVER['HTTP_USER_AGENT'],$useragents)) {
echo 'This is a mobile device ' . $_SERVER['HTTP_USER_AGENT'];

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum