How to Enable My Website for Mobile Version
Moderator: General Moderators
How to Enable My Website for Mobile Version
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...
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
Check the user-agent. This can be done in PHP, Javascript, or possibly even .htaccess.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: How to Enable My Website for Mobile Version
Thanks
Can you please explain me in detail so that i can complete the task....
Can you please explain me in detail so that i can complete the task....
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: How to Enable My Website for Mobile Version
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"
if() + $_SERVER['HTTP_USER_AGENT'] + strpos() for "mobile"
Re: How to Enable My Website for Mobile Version
have u done the task recentaly, if yes please share teh code...
Thanks,
Dhiraj Kr.
Thanks,
Dhiraj Kr.
-
priyanka123
- Forum Newbie
- Posts: 1
- Joined: Mon Apr 26, 2010 5:16 am
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: How to Enable My Website for Mobile Version
No. Why don't you try posting what you have tried, and we will help you from there.Pirontech wrote:have u done the task recentaly, if yes please share teh code...
Thanks,
Dhiraj Kr.
Re: How to Enable My Website for Mobile Version
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.
This is something I picked up a while ago from the web.
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");
}
?>Re: How to Enable My Website for Mobile Version
Ya Sure i will post if i find any thing extra for MObiles