Forum Discussion

Danny_Trinh_197's avatar
Danny_Trinh_197
Icon for Nimbostratus rankNimbostratus
Feb 04, 2009

Better way to do if {...}

Hello,

 

I have the iRule below, it works; but I think there is a better way for my iRule. Can you give me a hint?

 

Thanks,

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::host]] eq "qipclient" && [HTTP::path] eq "/" } {

 

HTTP::redirect "http://qip.example.com/qip"

 

}

 

if { [string tolower [HTTP::host]] eq "qip.iss.example.com" && [HTTP::path] eq "/" } {

 

HTTP::redirect "http://qip.example.com/qip"

 

}

 

if { [string tolower [HTTP::host]] eq "qip" && [HTTP::path] eq "/" } {

 

HTTP::redirect "http://qip.example.com/qip"

 

}

 

if { [string tolower [HTTP::host]] eq "qipclient.example.com" && [HTTP::path] eq "/" } {

 

HTTP::redirect "http://qip.example.com/qip"

 

}

 

if { [string tolower [HTTP::host]] eq "qip.example.com" && [HTTP::path] eq "/" } {

 

HTTP::redirect "http://qip.example.com/qip"

 

}

 

if { [string tolower [HTTP::host]] eq "qipwebclient.example.com" && [HTTP::path] eq "/" } {

 

HTTP::redirect "http://qip.example.com/qip"

 

}

 

if { [string tolower [HTTP::host]] eq "qip-es.example.com" && [HTTP::path] eq "/" } {

 

HTTP::redirect "http://qip.example.com/qip"

 

}

 

if { [string tolower [HTTP::host]] eq "raildns.example.com" && [HTTP::path] eq "/" } {

 

HTTP::redirect "http://qip.example.com/qip"

 

}

 

if { [string tolower [HTTP::host]] eq "raildns" && [HTTP::path] eq "/" } {

 

HTTP::redirect "http://qip.example.com/qip"

 

}

 

if { [string tolower [HTTP::host]] eq "raildns.iss.example.com" && [HTTP::path] eq "/" } {

 

HTTP::redirect "http://qip.example.com/qip"

 

}

 

}

 

  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    when HTTP_REQUEST {  
       if { [HTTP::path] eq "/" } { 
         switch [string tolower [HTTP::host]] { 
           "qipclient" -   
           "qip.iss.example.com" - 
           "qip" - 
           "qipclient.example.com" - 
           "qip.example.com" - 
           "qipwebclient.example.com" - 
           "qip-es.example.com" - 
           "raildns.example.com" - 
           "raildns" - 
           "raildns.iss.example.com" { 
             HTTP::redirect "http://qip.example.com/qip" } 
           } 
         } 
       }  
     }