Detecting and automatically redirecting website visitors who visit a standard webpage / website on mobile, handheld, wireless, PDA, or cel / cell phone devices / browsers to a mobile version of the webpage or website

DEPRECIATED – For an up-to-date version of the Studio Hyperset PHP mobile redirect script, please visit SH‘s Google code project site. To read more about the script, please visit this hyper/boʊl/e post and the mobile redirect code discussion index.

In developing the Studio Hyperset mobile website, I must have searched every combination of the following word group: “mobile, redirect, browser, automatic, detect, wireless, device, handheld, PDA, cell, cel, phone.” Just imagine the host of indefinite and definite articles I had to scatter in there like pepper to make phrases in the Google box!

I was trying to find hints on and/or scripts that would allow me to detect and automatically redirect website visitors who visited a standard webpage / website on mobile, handheld, wireless, PDA, or cel / cell phone devices / browsers to a mobile version of the webpage or website.

I found next to nothing; but using these three extremely helpful sites, Zytrax.com, a Nokia discussion forum, and a MSDN blog called Pla.NET Southeast!, I think I was able to piece together three bits of code that will:

  • scan a visitor’s platform (using .asp HTTP_USER_AGENT strings);
  • scan a visitor’s browser type (using .php USER_AGENT strings);
  • and generally check to see what type of device the visitor is using.

I hope these will allow me to detect and automatically redirect website visitors to the standard Studio Hyperset homepage on mobile, handheld, wireless, PDA, or cel / cell phone devices / browsers to the SH mobile page.

I want to share these scripts for development and troubleshooting; and in the best humanistic spirit of the WWW, I wanted to make them available in the hopes that others who share the need to detect and automatically redirect website visitors who visit a standard webpage / website on mobile, handheld, wireless, PDA, or cel / cell phone devices / browsers to a mobile version of the webpage or website will be saved the trouble I went through.

I’ve posted the scripts as a .zip file here: http://studiohyperset.com/resources/redirect.zip. (A single PHP file is now hosted at Google Code.) I make no proprietary claim over these scripts whether to sell them or claim credit from them. All I ask those who use the script to do is post a comment that you used the scripts and whether or not (and how) you improved them. This way, I can put out additional, improved versions of the scripts or, if necessary, drop one or two to concentrate on developing the remaining one or two.

About the scripts

mobile.php
Drawing on the list of Zytrax Mobile Browser ID (User-Agent) Strings, this .php file asks the visitor’s server to identify the browser s/he is using. If it’s one of the mobile browsers listed (Opera Mini, AvantGo, ReqwirelessWeb, &tc.), the user is redirected to the mobile version of Studio Hyperset. If the user’s browser isn’t on the list, s/he is passed on to the standard homepage. Of the three, I have the most faith in this one as the User Agents are well defined and quite specific.

mobile.asp
Drawing on the .asp code listed on the Nokia discussion forum – having added quite a few additional platforms to the list myself – this .asp file asks the visitor’s server to identify the platform s/he is using. If it’s one of the mobile platforms listed (Palm, PocketPC, Samsung, &tc.), the user is redirected to the mobile version of Studio Hyperset. I have a bit less faith in this one because it’s a general, trade-name list of platforms rather than a specific list of codes and the like. Still, though, it will probably work if the server can identify keywords in the User Agent string.

mobile2.asp
I’d be surprised if this one actually works alone. Still, I’ve included it as a catch all should the other two scripts miss something. The “if (Request.Browser["IsMobileDevice"] == "true" )” string just seems too simplistic to actually work. It’s too general, especially when compared to the specificity of the “mobile.php” script.

Remember, as the the pace of mobile technology development continues to increase, more and more platforms and browsers will need to be added to the list. I encourage us all to stay on top of these developments and add platforms and browsers to these code strings.

I invite comments, suggestions, additions, and ideas.

I hope this fills the void in the Internet where heretofore easy-to-use, reliable scripts of this sort could not be easily found.

Posted in "Métier."

Tags:

Quimby Melton

Founder/President, Director of Operations & Media Developer

Quimby started Studio Hyperset in 2006 after studying Transatlantic literature and culture, new media, and humanities computing at the Universities of Georgia (AB, 00) and Nevada, Las Vegas (MA, 03; PhD, 08). Apart from his work with SH, Quimby's published work in Bright Lights Film Journal, SCRIPTjr.nl, and elsewhere online and serves as executive producer of Live Free or Die!