Forum Discussion
when HTTP_REQUEST {
set vurl [HTTP::host][HTTP::path]
if { $vurl starts_with "xxx.test.com/tester/tester122"} {
pool pool_name_a
} elseif { $vurl starts_with "xxx.test.com/tester"} {
pool pool_name_b
} else {
# no change to traffic
}
}
Probably something along these lines, with the more specific one first, as the less specific one otherwise will catch both.
Another point, if you have a lot of cases, like 20+, then it'd be a good idea to change to from repeated if statements to data groups.
If you don't need to test for domain you can remove the [HTTP::host] from the variable and the if statements
A lot of the time you can find inspiration to irules on clouddocs. For me "if" is bit more versatile, so I'll typically use it for these shorter rules. If you have a longer rule where you test a lot on the same variable then the Switch could be better.
The better advice would probably be to steer you towards http policies that can do this in a more user friendly/intuitive way... but I like irules.
thanks Heino for your help, I'll give it a shot
Phong