Forum Discussion
Andrew_Hinkley_
Nimbostratus
May 16, 2007iRule and default pool
I have this irule applied to a virtual server with a default pool of "MYPOOL", to take an HTTP request and redirect to HTTPS while maintaining the query string. Is the below "else" statement necessary, or will the irule use the default pool if the conditional statement is not matched? In testing it seems to work with the else statement, but I want to verify the functionality.
rule HTTP_to_HTTPS.login.irule {
when HTTP_REQUEST {
redirect /root/login.asp to https
if { [HTTP::uri] matches_regex "/root/login.asp"} {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
} else {
pool MYPOOL
}
}
}
If I just use the below irule is this functionally equivalent?
rule HTTP_to_HTTPS.login.irule {
when HTTP_REQUEST {
redirect /root/login.asp to https
if { [HTTP::uri] matches_regex "/root/login.asp"} {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
}
}
-andrew
1 Reply
- Colin_Walker_12Historic F5 AccountYes, the second example should be functionally the same if you have the default pool set on the Virtual.
Also, as a side note, you can save a lot of processing overhead by replacing your regular expression with a simple equivalence match using either "equals", "ends with" or "contains" as necessary to achieve the result you're looking for.
Something like"when HTTP_REQUEST { redirect /root/login.asp to https if { [HTTP::uri] equals "/root/login.asp"} { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } }
HTH,
Colin
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
