Forum Discussion

f5now_28704's avatar
f5now_28704
Icon for Nimbostratus rankNimbostratus
Oct 22, 2007

combining two redirect irules

He guys, I have two irules that I didnt know if I could make them in to one both are redirection.

 

 

1.

 

when HTTP_REQUEST {

 

if { [HTTP::uri] eq "/application.aspx" } {

 

HTTP::redirect "https://www.google.net/application.aspx"

 

}

 

}

 

 

2.

 

when HTTP_REQUEST {

 

if { [HTTP::host] equals "google.net" } {

 

HTTP::redirect "http://www.google.net[HTTP::uri]"

 

}

 

}

 

 

 

I tryied this...looks to work

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] eq "/application.aspx" } {

 

HTTP::redirect "https://www.google.net/application.aspx"}

 

else {

 

if { [HTTP::host] equals "google.net" } {

 

HTTP::redirect "http://www.google.net[HTTP::uri]"

 

}

 

}

 

}

 

 

is there a cleaner way for this or is this fine.

1 Reply

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    That looks fine. When including multiple redirects in a rule, or multiple rules for the same VIP, you just have to make sure that two redirects can't be issued for one HTTP request.

    You can combine the else and the following if to simplify it:

    
    when HTTP_REQUEST {
       if { [HTTP::uri] eq "/application.aspx" } {
          HTTP::redirect "https://www.google.net/application.aspx"
       } elseif { [HTTP::host] equals "google.net" } {
          HTTP::redirect "http://www.google.net[HTTP::uri]"
       }
    }

    Aaron