Forum Discussion

azakaria_102538's avatar
azakaria_102538
Icon for Nimbostratus rankNimbostratus
Dec 28, 2013

Smartphone detection

Hi: kindly i need an IRULE that when a smartphone need to access URL www.mysite.com\AAA to redirect it to another link www.mysite.com\BBB

 

thanks for help

 

1 Reply

  • This is actually a somewhat complicated problem. Firstly, you have to decide what constitutes a "smartphone". Does it include sub-tablet devices that are marketed as a phone? Do you really want just phones, or do you want other "mobile devices" (like the iPod or Nexus tablet)?

     

    Generally speaking, it is widely considered best practice to employ Responsive Web Design or one of its cousins to solve this problem if the desired goal is to match page layout (and to some extent, content) to a particular device. This approach is simultaneously more flexible and more exact.

     

    Having said that, sometimes client detection is the only way to go. A common method for accomplishing this is to use the User-Agent HTTP header. Unfortunately, the list of possible user-agent strings is huge and ever-growing. Something like OpenDDR or Detect Mobile Browsers can help, but they're implemented as part of the web application.

     

    On an LTM, there are a few ways to accomplish the rewriting you want. I would recommend creating an iRule that utilizes a data group. The data group would contain the User-Agent strings that match mobile devices that you want. If the the Request-URI matches something you want to re-write, and there is a datagroup match, you would then rewrite the relevant part of the Request-URI. If you choose to go this way, the class method description is a good place to start. There are some helpful resources on , including an overview of classes and data group files. Be aware that these are somewhat dependent on BIG-IP version. And, of course, you will also find similar questions and answers elsewhere on DevCentral.