Server Side Scripting for Mobile Detection and Redirection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • quushich
    New Member
    • May 2007
    • 9

    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.

    (Someone in the mobile site forum suggested I post in this one)

    Thanks in advance...
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    What are you using to detect? ASP can't really help at that point, javascript maybe?

    Jared

    Comment

    • quushich
      New Member
      • May 2007
      • 9

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

      <%
      userAgent = Request.ServerV ariables("HTTP_ USER_AGENT")
      isMobile = false
      if((InStr(userA gent, "AvantGo") > 0) OR (InStr(userAgen t, "Windows CE") > 0) OR (InStr(userAgen t, "NetFront") > 0) OR (InStr(userAgen t, "BlackBerry ") > 0) ) then
      isMobile = true
      end if
      if isMobile then
      response.redire ct("http://www.namesandnum bers.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...

      Comment

      • jhardman
        Recognized Expert Specialist
        • Jan 2007
        • 3405

        #4
        Ah, detected thru the server variables, I hadn't thought to do it that way. Good job and thanks for posting your solution.

        Jared

        Comment

        Working...