Operation not supported. Multiple redirect/respond invocations not allowed
I am receiving the following error in the ltm log (private data has been modified).
TCL error: redirect_irule - Operation not supported. Multiple redirect/respond invocations not allowed (line 9) invoked from within "HTTP::respond 307 "Location" "https://www.fruit.com[HTTP::uri]"
I have seen previous posts on the error, but cannot find a way to perform all of the redirects without multiple response/redirect lines in the irule. The iRule is listed below.
when HTTP_REQUEST { set host [HTTP::host] set uri [HTTP::uri]
switch -glob [string tolower [HTTP::host]] { "lemons.com" { HTTP::respond 301 "Location" "https://www.fruit.com/links/test?[HTTP::query]" } } if { $host contains "apples.com" and $uri contains "tree" } { HTTP::respond 307 "Location" "http://web.fruit.com/tree.aspx" } else { HTTP::respond 307 "Location" "https://www.fruit.com[HTTP::uri]" } }
The goal is to have the redirects in place. Currently, the LTM is intermittently sending resets (RSTs) back to the client for www.lemons.com and lemons.com. Sometimes the browser issues a redirect and other times it doesn't due to the reset.
www.lemons.com -> redirect to https://www.fruit.com/links/test?[HTTP::query] lemons.com -> redirect to https://www.fruit.com/links/test?[HTTP::query] www.apples.com -> redirect to https://www.fruit.com apples.com/tree -> redirect to https://www.fruit.com/[HTTP::uri]
Thanks.