Forum Discussion

muzammil_88686's avatar
muzammil_88686
Icon for Nimbostratus rankNimbostratus
Mar 03, 2013

Non Smartphone iRule

Dear Dev Team,

 

 

Could you pls let me know the Irule for "Non-Smartphone" devices?

 

If the "Non-Smartphone" device initiates the traffic to "mobile.xyz.com" it should redirect the traffic to "www.xyz.com"

 

 

Best Regards,

 

4 Replies

  • you may use HTTP::header User-Agent to check whether it is mobile browser.

     

     

    HTTP::header wiki

     

    https://devcentral.f5.com/wiki/irules.HTTP__header.ashx

     

     

    List of all Mobile Browsers

     

    http://www.useragentstring.com/pages/Mobile%20Browserlist/
  • Thank you for your response!

     

     

    I have a rule as below

     

    =========

     

     

    switch [string tolower [HTTP::path]] {

     

     

    "/"

     

    {

     

    if { [class match [string tolower [HTTP::header User-Agent]] contains Mobile_Datagroup ] } {

     

    HTTP::redirect "http://www.xyz.com/mobile"

     

    log local0. "[IP::client_addr]:[TCP::client_port]: UA: [HTTP::header User-Agent], Mobile Device Detected"

     

    }

     

    else {

     

    HTTP::redirect "http://www.xyz.com/index" }

     

    }

     

     

     

    class Mobile_Datagroup {

     

    {

     

    "BB10"

     

    "Motorola"

     

    "android"

     

    "bb10"

     

    "blackberry"

     

    "htc"

     

    "iphone"

     

    "lg"

     

    "nokia"

     

    "palm"

     

    "samsung"

     

    "sonyericsson"

     

    "symbian"

     

    "vodafone"

     

    }

     

    }

     

    =========

     

     

    Currently the above rule is working fine with"Smartphones".

     

     

    In similar way, we would like to detect "Non-Smartphone" device which initiates the traffic to "mobile.xyz.com" and it should redirect the traffic to "www.xyz.com"

     

     

    Could you pls suggest me with the irule?
  • are both www.xyz.com and mobile.xyz.com resolved to same ip (virtual server)?

     

     

    if so, is this applicable?

     

     

    when HTTP_REQUEST {

     

    switch [string tolower [HTTP::path]] {

     

    "/" {

     

    if { [HTTP::host] equals "www.xyz.com" } {

     

    if { [class match [string tolower [HTTP::header User-Agent]] contains Mobile_Datagroup] } {

     

    www.xyz.com but mobile browser

     

    do something

     

    } else {

     

    www.xyz.com and pc browser

     

    do something

     

    }

     

    } else {

     

    if { [class match [string tolower [HTTP::header User-Agent]] contains Mobile_Datagroup] } {

     

    NOT www.xyz.com and mobile browser

     

    do something

     

    } else {

     

    NOT www.xyz.com but pc browser

     

    do something

     

    }

     

    }

     

    }

     

    }

     

    }

     

  • Thank you for your response!

     

     

    No, both the www.xyz.com and mobile.xyz.com are belongs to two different Virtual Servers which resides on two different LTMs