Connecting Tech Pros Worldwide Help | Site Map

Server Side Scripting for Mobile Detection and Redirection

 
LinkBack Thread Tools Search this Thread
  #1  
Old May 15th, 2007, 07:05 PM
Newbie
 
Join Date: May 2007
Location: Texas
Posts: 7
Default Server Side Scripting for Mobile Detection and Redirection

Hi all...

I need some help figuring out what sort of script is needed to first: detect if a viewer is coming from a mobile device and second: if so, redirect the viewer to the mobile site.

IIS Server
home site: site.com
mobile site: site.com/mobile

I have researched and found code to implement... but it was for an .htaccess file for use on APACHE.


Thanks in advance...
Reply
  #2  
Old May 15th, 2007, 11:48 PM
kestrel's Avatar
Moderator
 
Join Date: Jul 2006
Location: California!!!
Posts: 898
Default

What server-side scripting language are you using? ASP right?

i don't know much about server-side anything beyond knowing its done by the server, but i know browser detection and redirection is possible. How this is done and used i do not know.
Reply
  #3  
Old May 16th, 2007, 02:38 PM
Newbie
 
Join Date: May 2007
Location: Texas
Posts: 7
Default

Yes... ASP.
Reply
  #4  
Old May 16th, 2007, 10:55 PM
kestrel's Avatar
Moderator
 
Join Date: Jul 2006
Location: California!!!
Posts: 898
Default

You would get a better answer in the ASP forum. The experts and mods there have a better understanding ASP and they would be happy to point you in the right direction.
Reply
  #5  
Old May 18th, 2007, 02:02 PM
Newbie
 
Join Date: May 2007
Posts: 8
Default

I think you need WURFL on sourceforge dot net.

You can implement the code using several different languages (php,asp, and Java) but you're going to need a bit of programming skill to do much with it ;)

The information as to what is looking at pages on your server is sent via a http header (think this is the correct term), the browser and device information is contained in something called the 'User Agent', the type of files that the browser can handle is sent in the 'Accept' header.

Have a go browsing some of these terms and see how you get on.

I'm no expert but I've found php a good language to work in, maybe you should give that a go.

Matthew
Reply
  #6  
Old May 18th, 2007, 10:30 PM
kestrel's Avatar
Moderator
 
Join Date: Jul 2006
Location: California!!!
Posts: 898
Default

i think IIS only uses aspm correct?
Reply
  #7  
Old May 22nd, 2007, 09:46 PM
Newbie
 
Join Date: May 2007
Location: Texas
Posts: 7
Default

Here is what we have so far... placed in the head of the original index.html file:

<%
userAgent = Request.ServerVariables("HTTP_USER_AGENT")
isMobile = false
if((InStr(userAgent, "AvantGo") > 0) OR (InStr(userAgent, "Windows CE") > 0) OR (InStr(userAgent, "NetFront") > 0) OR (InStr(userAgent, "BlackBerry") > 0) ) then
isMobile = true
end if
if isMobile then
response.redirect("http://www.namesandnumbers.com/mobile")
end if
%>

Seems to be doing the trick... just had to save the index.html file to an index.asp file and then had the server point to the .asp as priority.

We will then add any other "mobile" users to the list above for detection...
Reply
  #8  
Old May 23rd, 2007, 11:32 AM
Newbie
 
Join Date: May 2007
Posts: 8
Default

Good start, but you're going to need a much bigger database of devices if you want to capture any meaningful proportion of people. For example here's the user agent for a Nokia N73:

NokiaN73-1/3.0704.1.0.1 Series60/3.0 Profile/MIDP-2.0 Configuration/CLDC-1.1

And the same N73 with Opera Mini:
Opera/8.01 (J2ME/MIDP; Opera Mini/3.1.7196/1630; en; U; ssr)

Also, there are a bunch of devices that depending on what you're looking for could appear to be a web browser (MSIE).

For example the Palm Treo 180:
Mozilla/1.22 (compatible; MSIE 5.01; PalmOS 3.0) EudoraWeb 2.1

Seems that there is very little standardization as to what a user agent needs to communicate, so for now the best thing I've found was the WURFL database.

Matthew
Reply
  #9  
Old June 15th, 2007, 02:32 PM
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 6,720
Default

Quote:
Originally Posted by quushich
Hi all...

I need some help figuring out what sort of script is needed to first: detect if a viewer is coming from a mobile device and second: if so, redirect the viewer to the mobile site.
The headers sent from a "cell phone" internet browser contain different values.
Check things like "Accept-Encoding" (is usually gzip or some form of compression) and "Accept-Type" will contain different types also it should ID itself as to what browser it is (MWAVE or something).
Reply
  #10  
Old June 10th, 2009, 09:16 PM
Newbie
 
Join Date: Jun 2009
Posts: 1
Default Can anyone give a JSP equivalent

Can anyone give a JSP equivalent of the Request.ServerVariable example above?

I am on an OpenCMS 6 system and trying to detect for Windows Mobile and redirect accordingly.

I suppose I could just develop and HTML page and a separate CSS file with a media="handheld" attribute and use JavaScript to dynamically serve the CSS file but I'm reading a lot of forums that say JavaScript is a dicey proposition at best on many handheld clients.
Reply
  #11  
Old July 3rd, 2009, 01:45 AM
Newbie
 
Join Date: Jul 2009
Posts: 1
Default

EasyMobilizer has javascript mobile detection code that you are after. Include in head of index and forks to /mobile or whatever dir your mobile site is in
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.