Forum Discussion

lbeng_107406's avatar
lbeng_107406
Icon for Nimbostratus rankNimbostratus
Jan 22, 2010

HTTP::redirect iRule with uri exclusion

I am trying to develop an iRule that redirects based on the HTTP user-agent but is ignored if the uri is /doc.

 

 

Can anyone assist?

 

 

software version = 9.3.1 hotfix 4

 

 

when HTTP_REQUEST {

 

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

 

"*blackberry*" -

 

"*windows ce*" -

 

"*palm*" -

 

"*sonyericsson*" -

 

"*mot-*" -

 

"*netfront*" -

 

"*nokia*" -

 

"*samsung*" -

 

"*smartphone*" -

 

"*symbian*" {

 

 

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

 

}

 

else { pool www.xyz.com_80

 

}

 

}
  • Hi lbeng,

    You could write up with a IF nesting the switch statement

     
      
     when HTTP_REQUEST { 
       if { !([HTTP::uri] eq "/doc") } { 
         switch -glob [string tolower [HTTP::header User-Agent]] { 
           "*blackberry*" - 
          "*windows ce*" - 
          "*palm*" - 
          "*sonyericsson*" - 
          "*mot-*" - 
          "*netfront*" - 
          "*nokia*" - 
          "*samsung*" - 
          "*smartphone*" - 
          "*symbian*" {  
              HTTP::redirect "http://mobile.xyz.com"  
                      } 
         } 
      } else { 
         pool www.xyz.com_80 
      } 
     } 
     

    I hope this helps

    Bhattman