Forum Discussion

Thamer_3789's avatar
Thamer_3789
Icon for Nimbostratus rankNimbostratus
Sep 23, 2012

mobile device redirection

Hi All;

 

i want to apply this iRule to redirect the mobile devices traffic to another web site by detecting the "user agent" header...may you check it guys !!!!

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::host][HTTP::uri]] contains "www.mysite.com" } {

 

if { [class match [string tolower [HTTP::header User-Agent]] equals mobile_device_types ] }{

 

HTTP::redirect "http://m.mysite.com"}

 

}

 

}

 

 

 

 

* Where " mobile_device_types " is a data group ...

 

Thanks in advanced

 

3 Replies

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus
    Thamer,

     

     

    From a quick glance it looks fine. My suggestion would be use "contains" rather than "equals" as to match every user-agent that way in your data group sounds like a lot of work. You could then do generic variables like "mobile" in the data group. Unless of course you want to be very specific on the user-agents. Just my two penneth..

     

     

    Hope it works

     

     

    N
  • As Nathan said, maybe something like this:

    
    when HTTP_REQUEST {
    if { [string tolower [HTTP::host]] equals "www.mysite.com" } {
    if { [class match [string tolower [HTTP::header User-Agent]] contains mobile_device_types ] }{ 
    HTTP::redirect "http://m.mysite.com"
    }
    }
    }
    

    Aaron