Page 1 of 1

How to Enable My Website for Mobile Version

Posted: Fri Apr 23, 2010 8:07 am
by Pirontech
Hi All,

i am developing a site (www.flexiguru.com) now i want to run this site on mobiles, i know how to design the website for the MObile.

Use Low CSS and Less Images and Layout shoud be 320*264.

but i dont know how to dedect that the website opened in the mobile.

i have uploaded my website bt creating a subdomain www.mobile.flexiguru.com.

But user type Only www.flexiguru.com on his mobile only and automaticaly user redirect to the subdomain which have the Mobile Designed Pages i mean user must redirect on www.mobile.flexiguru.com

Please help me..................

Thnx in Advance...

Re: How to Enable My Website for Mobile Version

Posted: Fri Apr 23, 2010 9:51 am
by pickle
Check the user-agent. This can be done in PHP, Javascript, or possibly even .htaccess.

Re: How to Enable My Website for Mobile Version

Posted: Fri Apr 23, 2010 11:57 pm
by Pirontech
Thanks

Can you please explain me in detail so that i can complete the task....

Re: How to Enable My Website for Mobile Version

Posted: Sat Apr 24, 2010 12:01 pm
by John Cartwright
You'll have to collect a list of mobile user agents, and perhaps they all share the keyword "mobile" or something similiar. In that case, it would involve

if() + $_SERVER['HTTP_USER_AGENT'] + strpos() for "mobile"

Re: How to Enable My Website for Mobile Version

Posted: Mon Apr 26, 2010 1:11 am
by Pirontech
have u done the task recentaly, if yes please share teh code...


Thanks,

Dhiraj Kr.

Re: How to Enable My Website for Mobile Version

Posted: Mon Apr 26, 2010 5:30 am
by priyanka123
Testing

Re: How to Enable My Website for Mobile Version

Posted: Mon Apr 26, 2010 9:40 am
by John Cartwright
Pirontech wrote:have u done the task recentaly, if yes please share teh code...


Thanks,

Dhiraj Kr.
No. Why don't you try posting what you have tried, and we will help you from there.

Re: How to Enable My Website for Mobile Version

Posted: Mon Apr 26, 2010 10:55 am
by abushahin
Ok here you go, this works with alot of mobile user agents feel free to add more later known mobile user agents, if you do find them then please post here so that we can also add to our array.

Code: Select all

<?php
 
$mobile_browser = '0';
 
if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
    $mobile_browser++;
}
 
if((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml')>0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
    $mobile_browser++;
}    
 
$mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,4));
$mobile_agents = array(
    'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
    'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
    'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
    'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
    'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
    'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
    'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
    'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
    'wapr','webc','winw','winw','xda','xda-');
 
if(in_array($mobile_ua,$mobile_agents)) {
    $mobile_browser++;
}
 
if (strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini')>0) {
    $mobile_browser++;
}
 
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows')>0) {
    $mobile_browser=0;
}
 
if($mobile_browser>0) {
   header("Location: http://www.mobile.site.com");
exit;
}
else {
   header("Location: http://www.site.com");
}   
 
?>
This is something I picked up a while ago from the web.

Re: How to Enable My Website for Mobile Version

Posted: Mon May 03, 2010 1:16 am
by Pirontech
Ya Sure i will post if i find any thing extra for MObiles