Forum Discussion
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 "; } }
- Vijay_ECirrus
You can create a datagroup/class and use it within iRule. The datagroup/class will contain all the matching domains names.
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 "; } }
- Nandhini_NataraNimbostratus
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 "; } }
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com