For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

chungyu_16122's avatar
chungyu_16122
Icon for Altostratus rankAltostratus
Oct 16, 2015

How do I combine multiple irules doing redirects to a single irule?

Hi all

 

Has someone worked on a similar set i=of irules?

 

I currently have 2 separate irules to redirect users to a specific page; however, I would like to create a single rule that combines into 1 irule.

 

Rule 1

 

when HTTP_REQUEST { if {[HTTP::host] equals "infogood" and ([HTTP::uri] equals "/cu/en/legacylogin.jsp" or [HTTP::uri] equals "/cu/en/legacylogin.jsp/")} { HTTP::redirect "http://www.school.com/it/" } elseif {[HTTP::host] equals "education-account-identification.com" } { HTTP::redirect "http://www.school.com/it/" } }

 

Rule 2

 

when HTTP_REQUEST { {[HTTP::host] equals "www.schoolpermit.com"} { HTTP::redirect "http://www.school.com/it/" } }

 

Now, I tried to combine them with an "else" switch and dropping the "when HTTP_REQUEST on irule 2 but I get errors loading the irule.

 

Also, should I add the "string tolower" switch?

 

2 Replies

  • Try something like this.

    when HTTP_REQUEST { 
        switch [string tolower [HTTP::host]] {
            "www.infogood.com" {
                switch [string tolower [HTTP::uri]] {
                    "/cu/en/legacylogin.jsp" -
                    "/cu/en/legacylogin.jsp/" {
                         HTTP::redirect "http://www.school.com/it/" 
                    }
                }
            }
            "education-account-identification.com" {
                HTTP::redirect "http://www.school.com/it/" 
            }
            "www.schoolpermit.com" {
                HTTP::redirect "http://www.school.com/it/"
            }
        }
    }
    
  • Hi Michael

     

    Thanks a lot, I will try this out and post the results.

     

    Regards

     

    Chung