Forum Discussion
Brent_Sachnoff_
Nimbostratus
May 24, 2006funny things happen with basic iRule
Hi. I have this iRule that appeared to work the first couple of times around and now only works for the 1,2 and last case within the if clause. I'm sure there is a better way to write it but I'm sti...
May 24, 2006
As long as the rule can compile (due to the elseif's on new lines), then it should functionaly work. I would add some logging in to output the values of the HTTP::host and HTTP::uri variables and then a log statement for the condition that matched. starts_with and equals are case-sensitive. Maybe that could be the issue. No way to tell without some input data.
BTW, in the future, I'd recommend avoiding elseif's and else's on newlines. That isn't supported by TCL and our implementation of that has some problems under certain situations such as trailing spaces on the previous lines).
I'd start with something like this:
when HTTP_REQUEST {
log local0. "Host: [HTTP::host], URI: [HTTP::uri]"
if { [HTTP::host] starts_with "a.company.com" } {
log local0. "host matched a.company.com"
HTTP::redirect "https://www.company.com/123/Login.html"
} elseif { [HTTP::host] starts_with "company.com" } {
log local0. "host matched company.com"
HTTP::redirect "https://www.company.com/123/Login.html"
} elseif { [HTTP::uri] equals "/" } {
log local0. "URI matched '/'"
HTTP::redirect "https://[HTTP::host]/123/Login.html"
} elseif { [HTTP::uri] equals "/Login.html" } {
log local0. "URI matched /Login.html"
HTTP::redirect "https://[HTTP::host]/123/Login.html"
} elseif { [HTTP::uri] equals "/456/index.html" } {
log local0. "URI matched /456/index.html"
HTTP::redirect "https://[HTTP::host]/123/Login.html"
} elseif { [HTTP::uri] equals "/mobileLogin.html" } {
log local0. "URI matched /mobileLogin.html"
HTTP::redirect "https://[HTTP::host]/123/Login.html"
} else {
log local0. "URI match not found, using default case"
HTTP::redirect https://[HTTP::host][HTTP::uri]
}
}Then take a look at the /var/log/ltm file on the BIG-IP to find out why your cases don't work.
-Joe
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