Forum Discussion
Irule not working as expected
- Oct 19, 2016
No need for any string command. If you don't want to normalize the case, then:
when HTTP_REQUEST { switch -glob [HTTP::uri] { ... etc ... } }
However, again, you probably want to use HTTP::path, since that's what you're actually matching on. For the case your provide, it would be something like this:
when HTTP_REQUEST { switch -glob [HTTP::path] { "*/MembershipEdit" { pool poolB } } }
For the example URL you provided, what you're trying to match is essentially "if the Target-Request path ends_with /MembershipEdit, then use poolB". With glob matching:
switch [HTTP::path] { "/foo" {...} ; means match if path is exactly /foo "*/foo" {...} ; means match if path ends with /foo "/foo/*" {...} ; means match if path starts with /foo/ "*/foo/*" {...} ; means match if path contains /foo/ }
For what it's worth, I suspect that what you really mean is:
when HTTP_REQUEST { switch -glob [HTTP::path] { "*/CustomerDetails" - "*/WebofferList" - "*/MembershipEdit" { pool poolB } } }
What I mean is, I suspect in all cases you are trying to match something at the end of the path, and since you are not normalizing the case (and generally, not normalizing the case of the path is the correct choice), then you must make sure the case matches.
No need for any string command. If you don't want to normalize the case, then:
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
... etc ...
}
}
However, again, you probably want to use HTTP::path, since that's what you're actually matching on. For the case your provide, it would be something like this:
when HTTP_REQUEST {
switch -glob [HTTP::path] {
"*/MembershipEdit" {
pool poolB
}
}
}
For the example URL you provided, what you're trying to match is essentially "if the Target-Request path ends_with /MembershipEdit, then use poolB". With glob matching:
switch [HTTP::path] {
"/foo" {...} ; means match if path is exactly /foo
"*/foo" {...} ; means match if path ends with /foo
"/foo/*" {...} ; means match if path starts with /foo/
"*/foo/*" {...} ; means match if path contains /foo/
}
For what it's worth, I suspect that what you really mean is:
when HTTP_REQUEST {
switch -glob [HTTP::path] {
"*/CustomerDetails" -
"*/WebofferList" -
"*/MembershipEdit" {
pool poolB
}
}
}
What I mean is, I suspect in all cases you are trying to match something at the end of the path, and since you are not normalizing the case (and generally, not normalizing the case of the path is the correct choice), then you must make sure the case matches.
- sandiksk_35282Oct 20, 2016Altostratus
Thanks for your response . Tried the above syntax and it is working.
Recent Discussions
Related Content
* 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