Forum Discussion
George_32239
Nimbostratus
Oct 27, 2009Multiple comparisons in an iRule
Hello All,
I need a rule that will look at a hostname the [HTTP::host] and also looke at part of the URI, the [HTTP:uri] bit.
If both conditions are the same I need to send the request to a certain pool if both sets do not match need to send them to another pool.
I don't know if an ANDIF statement exists.
Apologies in advance, our firm has not sent us on any training courses and am struggling with this
Any help greatly appreciated
Thanks,
George
3 Replies
- George_32239
Nimbostratus
I think I figured it out using the following;
when HTTP_REQUEST {
if { [HTTP::host] eq "somehost.com" && [HTTP::uri] contains "somestring"} {
pool some_pool }
else
{pool some_other_pool}
}
I am now going to try the string tolower bit
Thanks - hoolio
Cirrostratus
Hi George,
There are quite a few examples in the forums and the iRules wiki of iRules which check the host (retrieved using HTTP::host Click here) and the URI (retrieved using HTTP::uri Click here).
Here is one example of checking the host and URI to select corresponding pools:when HTTP_REQUEST { This event is triggered when LTM parses the HTTP request headers Check requested host using lower case if {[string tolower [HTTP::host]] eq "subdomain.example.com"}{ Check the requested URI if {[HTTP::uri] starts_with "/some_uri"}{ pool some_pool } else { pool other_pool } } else { pool some_other_pool } }
Aaron - George_32239
Nimbostratus
Hi Aaron,
Many thanks for your reply. I should have an environment I can test on tomorrow.
George
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
