Forum Discussion
Steve_Sutton_87
Nimbostratus
May 04, 2005why is log statement in else clause executing?
Hi,
I have the following rule:
if (http_uri == "/") {
log local0.info "test09si: redirected incomplete URI"
redirect to "https://%h/Test01_09"
}
else if (http_uri starts_with "/Test01_09") {
use pool test01-8180
}
else {
log local0.info "test09si: redirected for bad path "
redirect to "https://alpha.blueroads.com/error/404.html"
}
If I browse to https://test09si.blueroads.com, the if clause correctly redirects with the path, and the else if apparently evaluates true because I get to the web site just fine. However, the "log local0.info "test09si: redirected for bad path " is also being executed - in a fraction of a second I get both log messages logged into /var/log/bigip. But even though we appear to be stepping into the else clause, I don't get redirected to the 404 error page (that's a good thing, at least).
If I indeed provide a bad path, such as https://test09si.blueroads.com/Test01_08, the else if is indeed false, and we drop into the else, and both the log and redirect in the else clause execute.
Why is the log statement in the else clause executing?
Cheers,
Steve
4 Replies
- Could it be that the contents of your website's html code references another uri on that is causing the else clause to catch? First thing I'd do is to log the http_uri value at the beginning of the rule and then look at the logs. I'd be surprised if you see the "if" log statement followed by the "else". Odds are that another uri is slipping in under the covers somewhere (that would explain why the main page is redirecting correctly). Take a look and let us know.
- Steve_Sutton_87
Nimbostratus
I'd log the http_uri value if I could - but the log command doesn't appear to expand the http_uri variable? The doc says the log command will do variable expansion as in the header insert pool attribute. Looking at that, there are variables for client address and port, server address and port, link_qos and ip_qos - nothing that would provide either the path, or host, or even the entire URL. - Martin_MachacekHistoric F5 AccountUse:
if (http_uri == "/") { log local0.info "test09si: redirected incomplete URI" redirect to "https://%h/Test01_09" } else if (http_uri starts_with "/Test01_09") { use pool test01-8180 } else { log local0.info "test09si: redirected for bad path: " + http_uri redirect to "https://alpha.blueroads.com/error/404.html" }
- Steve_Sutton_87
Nimbostratus
Thanks - I'll give that a try.
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