Forum Discussion
I wrote a simplified variant of your iRule. Tested and works as expected.
when HTTP_REQUEST {
if { [HTTP::host] equals "www.myfancydomain.com" && [HTTP::uri] starts_with "/test" } {
node 10.100.153.40 3000
}
}
Note that I am matching the HTTP::host with equals, not with contains, because HTTP::host should be an exact match anyways.
Also I used HTTP::uri instead of HTTP::path and, but more important, I use starts_with, because HTTP::uri might also be /test/image1.jpg, test/index.html...
Differences between are explained here:
https://clouddocs.f5.com/api/irules/HTTP__path.html
https://clouddocs.f5.com/api/irules/HTTP__uri.html
Differences between contains, equals, starts_with and so on here:
https://devcentral.f5.com/s/articles/irules-101-02-if-and-expressions
And since you are always matching the same HTTP::host value, you might want to remove that check from your iRule logic and go for a switch statement to only match the HTTP::uri. Something like this.
switch -glob [HTTP::uri] {
"/foo*" {
# this will match on any string that starts with "/foo"
}
"*bar" {
# this will match on any string that ends with "bar"
}....
For details see here: https://devcentral.f5.com/s/articles/irules-101-04-switch