Forum Discussion

chungyu_16122's avatar
chungyu_16122
Icon for Altostratus rankAltostratus
Jul 10, 2012

iRule to redirect mobile browsers

Hi all

 

 

I started to use a irule I found on Dev Central to redirect blackberry, iphone, android, etc too a mobile site. But it semms that the re-direct is not able to take place, users just end up on the main site.

 

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::host]] contains "www.mcgill.ca/desautels" } {

 

switch -glob [string tolower [HTTP::header User-Agent]] {

 

"*blackberry*" -

 

"*iPhone*" -

 

"*Android*" -

 

"*Windows Phone OS 7*" -

 

}

 

{

 

HTTP::redirect "http://desautels.mobilizeme.com"

 

}

 

}

 

}

 

 

 

 

 

 

Has anyone done something similar to this??

 

 

 

Thanks in advance

 

 

 

Chung

 

  • can you try this?

    when HTTP_REQUEST {
       if { [string tolower [HTTP::host][HTTP::uri]] contains "www.mcgill.ca/desautels" } {
          switch -glob [string tolower [HTTP::header User-Agent]] {
             "*blackberry*" -
             "*iPhone*" -
             "*Android*" -
             "*Windows Phone OS 7*" {
                HTTP::redirect "http://desautels.mobilizeme.com"
             }
          }
       }
    }
    
  • oops! sorry, user-agent value should be in lowercase.

    when HTTP_REQUEST {
       if { [string tolower [HTTP::host][HTTP::uri]] contains "www.mcgill.ca/desautels" } {
          switch -glob [string tolower [HTTP::header User-Agent]] {
             "*blackberry*" -
             "*iphone*" -
             "*android*" -
             "*windows phone os 7*" {
                HTTP::redirect "http://desautels.mobilizeme.com"
             }
          }
       }
    }