Forum Discussion

Andyhsbos77's avatar
Andyhsbos77
Icon for Nimbostratus rankNimbostratus
Apr 23, 2018

Creating an iRule with multiple conditions

Hello, New to F5 and iRules here,

 

I'm looking to create an iRule that looks for certain urls and redirects them. I want to know though if i can combined them into one rule per redirected URL, so for example i created this below but not sure if it is correct. I was hoping to use [HTTP::URI] site1* but there is some directories they do not want to be redirected.

 

when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "site1/virtualdirector1/.aspx" } { HTTP::respond 301 Location "; } } elseif { [string tolower [HTTP::host]] equals "site1/virtualdirectory2/.aspx" } { HTTP::respond 301 Location "; } } elseif { [string tolower [HTTP::host]] equals "site1/virtualdirectory3/*.aspx" } { HTTP::respond 301 Location "; } }

 

  • Hello,

     

    You can create irule like the below one for multiple conditions

     

    ltm data-group internal host { records { site1/virtualdirector1/.aspx {} site1/virtualdirector2/.aspx{} site1/virtualdirector3/.aspx{} } type string }

     

    when HTTP_REQUEST { if {[class match [HTTP::host] equals host]} { HTTP::respond 301 Location "; } }

     

  • Hello,

     

    You can create irule like the below one for multiple conditions

     

    ltm data-group internal host { records { site1/virtualdirector1/.aspx {} site1/virtualdirector2/.aspx{} site1/virtualdirector3/.aspx{} } type string }

     

    when HTTP_REQUEST { if {[class match [HTTP::host] equals host]} { HTTP::respond 301 Location "; } }