Forum Discussion
andy_22730
Nimbostratus
Dec 19, 2008Use redirect and pools in same iRule?
I'm trying to build one irule that has all my logic in it, it will parse the URI of the request and send some URIs to a pool, but send others to external servers via HTTP::REDIRECT.
I don't seem to be able to do this in a single rule.
Should I use 2 rules? Is that slower?
Here is the logic of the rules:
when HTTP_REQUEST {
if {[HTTP::uri] starts_with "/foo"} {HTTP::redirect "http://foo.com"}
if {[HTTP::uri] starts_with "/bar"} {pool bar-pool}
}
I can create this irule, but anytime it matches to the bar, I get a tmm error about redirecting.... and it never redirects to the member of the pool.
- JRahm
Admin
TCL gets a little finicky with spacing, plus, you probably want an elseif instead of an if on that second conditional. Try this:when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/foo" } { HTTP::redirect "http://foo.com" } elseif { [string tolower [HTTP::uri]] starts_with "/bar" } { pool bar-pool } else { pool default-pool } }
- JRahm
Admin
edited post above...forgot a closing " - andy_22730
Nimbostratus
Excellent, this worked. WHat I ended up using: - JRahm
Admin
Check this thread for that capability:
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