Forum Discussion
TJ_Vreugdenhil
Sep 15, 2011Cirrus
Combine two iRules
Hi - I am trying to combine two iRules on 9.x.
I believe a switch -glob statement would be appropriate, but not sure how do it with two different HTTP::'operators.'
when HTTP_REQUEST {
if { !([HTTP::path] equals "http://test/niku/app") } {
HTTP::redirect "https://test.testmarketing.com[HTTP::uri]"
}
}
when HTTP_REQUEST {
if { [HTTP::host] equals "test" } {
HTTP::redirect "https://test.testmarketing.com[HTTP::uri]"
}
}
Suggestions?
Thanks!
-TJ
- Brian_69413NimbostratusI am not sure I follow completely, but it seems to me that this would do the trick:
when HTTP_REQUEST { if { ([HTTP::host] equals "test") & (!([HTTP::uri] equals "/niku/app")) } { HTTP::redirect "https://test.testmarketing.com[HTTP::uri]" } }
- Brian_69413NimbostratusReplace & with && or and
- nitassEmployeei think the 2nd HTTP_REQUEST is superset of the 1st one.
- Brian_69413NimbostratusI read the request as "I want to redirect all traffic to this host, except for this one path"
- nitassEmployeeI read the request as "I want to redirect all traffic to this host, except for this one path"
- Sorry for the confusion guys. Let me update some words so that it doesn't supersede itself.
- nitassEmployeepls feel free to revise.
[root@orchid:Active] config b virtual bar80 list virtual bar80 { snat automap pool foo80 destination 172.28.17.88:http ip protocol tcp rules myrule profiles http tcp } [root@orchid:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { if {[string tolower [HTTP::host]] equals "nice" and [string tolower [HTTP::uri]] ne "/niku/app"} { HTTP::redirect "https://nice.testmarketing.com[HTTP::uri]" } } } [root@orchid:Active] config curl -I http://nice/niku/app HTTP/1.1 404 Not Found Date: Thu, 15 Sep 2011 17:12:10 GMT Server: Apache/2.0.59 (rPath) Vary: Accept-Encoding Content-Type: text/html; charset=iso-8859-1 [root@orchid:Active] config curl -I http://nice/abc HTTP/1.0 302 Found Location: https://nice.testmarketing.com/abc Server: BigIP Connection: Keep-Alive Content-Length: 0
- Brian_69413NimbostratusBrian - I have always wanted some explanation to '&&'. This is an 'or' statement correct, not an 'and' statement, correct?
- Thanks for your help guys. Much appreciated!
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects