Forum Discussion
JeffM
Nimbostratus
Oct 24, 2014Having issue with multiple if statements for irule
What I am trying to do is have / and specific data group list URIs going to pool B and the rest of the traffic going to pool A. Issue is that when a URI contains part of an entry in the data group l...
kunjan_118660
Cumulonimbus
Oct 24, 2014that for example /legal-documents/ is defined in the data group list to (as it should) to point to the alternate pool but the URI /legal-documents/insurance needs to point to the default pool.
I think "starts_with" is the one which is failing here. You can have the original logic but change "starts_with" to "contains". But your dgl shouldn't have the end forward slash. Or if really wants the first if clause to remain, do a "return" so that next following if clause doesn't execute.
- JeffMOct 24, 2014
Nimbostratus
I did change the starts_with to contains but also had to do a re-write from if/if to elseif statements to trigger script exits upon successful match. This iRule is working. Thank you for your responses. when HTTP_REQUEST { if { ( [HTTP::uri] contains "/legal/documents" ) } { pool pool_host.domain.com_80 } elseif { ( [HTTP::uri] contains "/legal-notices/documents" ) } { pool pool_host.domain.com_80 } elseif { ( [HTTP::uri] contains "/legal-families/document-library" ) } { pool pool_host.domain.com_80 } elseif { ( [HTTP::uri] contains "/legal-producer/document-library" ) } { pool pool_host.domain.com_80 } elseif { ( [HTTP::uri] contains "/producer/document-library" ) } { pool pool_host.domain.com_80 } elseif { ( [HTTP::uri] equals "/" ) or ( [class match [string tolower [HTTP::uri]] contains dgl_host.domain.com_80] ) } { pool pool_ALThost.domain.com_80 } else { pool pool_host.domain.com_80 } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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