Forum Discussion
Leslie_South_55
Nimbostratus
Nov 18, 2006Logging with HTTP::redirect
I have a simple working iRule to redirect based on URI = /, send to http://yada.com/1/2/3
My issue is with the logging (I know...it's working and going where I want it to but I need to be able to show that in the log)
My rule is as follows
when HTTP_REQUEST {
log local0. "Uri is [HTTP::uri]"
if { [HTTP::uri] equals "/" } {
HTTP::redirect "http://www.yada.com/1/2/3/"
log local0. "redirecting to http://[HTTP::host]"
}
}
I am testing with an IP in the URL, so here is what I get in the log
Nov 18 13:29:32 tmm tmm[762]: Rule rule_test_redirect : Uri is /
Nov 18 13:29:32 tmm tmm[762]: Rule rule_test_redirect : redirecting to http://10.10.10.1/
I want to see "redirecting to http://www.yada.com/1/2/3" in the log.
What am I missing?
- A HTTP::redirect doesn't affect any of the current variables (HTTP::host or HTTP::uri), it just sends a HTTP redirect reply to the browser. By using these variables in your log statement, you will be accessing the values of the current original request (which isn't what you want). Why don't you just hard code the whole value in the log.
when HTTP_REQUEST { log local0. "Uri is [HTTP::uri]" if { [HTTP::uri] equals "/" } { log local0. "redirecting to http://www.yada.com/1/2/3/" HTTP::redirect "http://www.yada.com/1/2/3/" } }
- Leslie_South_55
Nimbostratus
Guess I did not realize that. I made the changes, and appreciate your response.
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