Jump to content

Mobile Sites


common

Recommended Posts

Hi

 

I am trying to create a site that determines the device's screen size. Most mobile phone browsers does not have javascript, so to determine the width and height of the screen I cannot use Javascript. Does anyone know how i can test whether a mobile phone is used to visit the site and what that phone's screen resolution is, so that I can redirect it to the right folder.

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/216861-mobile-sites/
Share on other sites

You can use .htaccess file

 

basically you'll have to expand on that .. what's happening here is all in the rewrite condition and rule - so to take an example from another blog:

 

RewriteCond %{HTTP_USER_AGENT} “Windows CE” [NC,OR] #Windows CE and Pocket PC

RewriteCond %{HTTP_USER_AGENT} “NetFront” [NC,OR] #PalmSource WebBrowser 2.0

RewriteCond %{HTTP_USER_AGENT} “Palm OS” [NC,OR] #Eudora Web Browser for Palm

RewriteCond %{HTTP_USER_AGENT} “Blazer” [NC,OR] #Handspring Blazer Browser

RewriteCond %{HTTP_USER_AGENT} “Elaine” [NC,OR] #RIM Devices

RewriteCond %{HTTP_USER_AGENT} “^WAP.*$” [NC,OR] #WAP Browsers

RewriteCond %{HTTP_USER_AGENT} “Plucker” [NC,OR] #Plucker Offline download client

RewriteCond %{HTTP_USER_AGENT} “AvantGo” [NC] #AvantGo Service

RewriteRule ^index.php http://m.yourdomain.com/ [L,R]

 

basically if the browser's user agent matches one of these strings, then the rewrite rule kicks in...

 

it's not the most basic of concepts and rewrite stuff can be quite touchy, so it could be tricky to implement, but that's how you'd go about it...

 

hope that helps a bit!

Link to comment
https://forums.phpfreaks.com/topic/216861-mobile-sites/#findComment-1126576
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.