473,382 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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...
May 15 '07 #1
8 16979
kestrel
1,071 Expert 1GB
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.
May 15 '07 #2
Yes... ASP.
May 16 '07 #3
kestrel
1,071 Expert 1GB
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.
May 16 '07 #4
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
May 18 '07 #5
kestrel
1,071 Expert 1GB
i think IIS only uses aspm correct?
May 18 '07 #6
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...
May 22 '07 #7
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
May 23 '07 #8
Plater
7,872 Expert 4TB
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).
Jun 15 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Matt | last post by:
I think this is the basic concept in ASP server-side development. My boss told me web application is NOT client-server application. I argued with him because browser is the client, and the server...
21
by: Agoston Bejo | last post by:
Hi, I would like to achieve the equivalent of META REFRESH but without the HTML meta refresh and without JavaScript. In other words, on server side I would like to wait some seconds, then redirect...
4
by: Jim Hammond | last post by:
After much effort, it doesn't seem possible to redirect the user to a new page after 10 seconds by using a server-side timer. I am now using the following meta statement to accomplish the same...
3
by: Ohad Young | last post by:
Hi, I have a frameset page that contains two frames: 1. the first frame, an aspx page, contains a menu for navigating in the website. 2. the second frame contains content, pdf, html or other...
0
by: Carlos | last post by:
Hi all, I am currently able to detect the browser capabilities, and determine if a browser is from a mobile device. However, I only have been able to place this detection code in an aspx page....
3
by: quushich | last post by:
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...
5
by: Ankur | last post by:
Hi Folks, I am new for this group. I want to clarify one thing what's a basic difference between Client Side Java Script and Server Side Java Script. how we can differentiate it. Why we called...
1
by: Sleepwalker | last post by:
Hi, I'm currently in the process of constructing a stripped down version of the company website that will be show to people logging in from a mobile device. When the user logs in to the homepage,...
22
by: Dan Rumney | last post by:
Hi all, I've been writing Javascript for quite a while now and have, of late, been writing quite a lot of AJAX and AJAX-related code. In the main, my dynamically generated pages are created...
1
by: jeremybwilson | last post by:
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.