Forum Discussion
Ryan_Chin_80280
Nimbostratus
Aug 19, 2005Multiple redirect/respond invocations not allowed
Hi Guys,
Need some help on a iRule i wrote, would appreciate if anyone can shed some light on what is wrong with it.
The iRule below is trying to do 3 things.
1) redirect all traffic to https
2) if user trys to access a specific URI '/exchange/customerservice', it will redirect back to /exchange
3) if user not does key in the URI '/exchange', it will redirect user to it.
=====================================================================
when HTTP_REQUEST {
redirect all traffic to https
if {[TCP::local_port] != "443"} {
HTTP::redirect https://[HTTP::host]/exchange
}
evaluate characters as lower case
Pass characters back to server in lower case
set my_uri [string tolower [HTTP::uri]]
log local0. "the uri is $my_uri"
if { $my_uri starts_with "/exchange/customerservice" } {
redirect to HTTPS on matching URI
HTTP::redirect https://[HTTP::host]/exchange
}
redirect if user does not key in exchange
if { [HTTP::uri] == "/" } {
HTTP::redirect https://[HTTP::host][HTTP::uri]/exchange
}
}
=====================================================================
The rule seems to be working, it was doing all the above, however, i keep seeing the error message below in my ltm log file. Anyone has any idea? Thanks alot!
=====================================================================
Aug 19 10:34:50 tmm tmm[707]: 01220001:3: TCL error: Rule GIOWA_filter - Operation not supported. Multiple redirect/respond invocations not allowed (line 15) invoked from within "HTTP::redirect https://[HTTP::host][HTTP::uri]/exchange"
=====================================================================
- Erick_Hammersm1Historic F5 AccountSince the rule will always evaluate each conditional, a single request could result in multiple HTTP::redirect statements. For example, a request for http://www.abc.com/ would match both the TCP::local_port != 443 and the HTTP::uri == "/" conditions. This rule will not encounter this problem:
when HTTP_REQUEST { if {[TCP::local_port] != "443"} { HTTP::redirect https://[HTTP::host]/exchange } else { set my_uri [string tolower [HTTP::uri]] if { $my_uri starts_with "/exchange/customerservice" } { HTTP::redirect https://[HTTP::host]/exchange } elseif { $my_uri eq "/" } { HTTP::redirect https://[HTTP::host][HTTP::uri]/exchange } } }
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