Multiple redirect not allowed

I have BigIP with Version 9.2.2. I have following iRule configured for my web site. I can not get redirect for uri starting with “/returns.jsp”. I am getting error saying “Multiple redirect are not supported” can you please check my rule and help me with error.

Thanks

--------------------------

iRule

when HTTP_REQUEST {

if {[HTTP::host] contains “staging.originalpenguin.com” and [HTTP::uri] contains “/fif=”}

{use pool pei_staging_8087_pool}

elseif {[HTTP::uri] contains “user” or [HTTP::uri] contains “checkout” }

{HTTP::redirect “https://[HTTP::host][HTTP::uri]” }

if {[HTTP::host] contains “staging.originalpenguin.com” and [HTTP::uri] starts_with “/dialogcentral”}

{use pool pei_staging_1080_pool}

elseif {[HTTP::host] contains “staging.originalpenguin.com” and [HTTP::uri] starts_with “/returns.jsp”} {HTTP::redirect “http://staging.originalpenguin.com/opg/service/customer\_care\_returns\_exchanges.jsphandling”}

if {[HTTP::host] contains “staging.originalpenguin.com” and [HTTP::uri] starts_with “/opg”}

{use pool pei_staging_1080_pool}

else {

HTTP::redirect “http://staging.originalpenguin.com/opg/”

}

}

------------------------------

Error Log on BigIP

Jun 22 16:54:06 tmm tmm[987]: 01220001:3: TCL error: Rule staging_http_2 REQUEST> - Operation not supported. Multiple redirect/respond invocations not allowed (line 12) invoked from within "HTTP::redirect “http://staging.originalpenguin.com/opg/” "

F5 has made some adjustments to default TCL behaviour to allow “else” to occur @ the beginning of a line, but I’d suggest re-arranging the structure of the rule so the “else” statements are on the same line as the “}”, to conform w/standard TCL syntax:

when HTTP_REQUEST {
if {[HTTP::host] contains "staging.originalpenguin.com" and [HTTP::uri] contains "/fif="}{
  use pool pei_staging_8087_pool
} elseif {[HTTP::uri] contains "user" or [HTTP::uri] contains "checkout" }{
  HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
} 
if {[HTTP::host] contains "staging.originalpenguin.com" and [HTTP::uri] starts_with "/dialogcentral"}{
  use pool pei_staging_1080_pool
} elseif {[HTTP::host] contains "staging.originalpenguin.com" and [HTTP::uri] starts_with "/returns.jsp"}{
  HTTP::redirect "http://staging.originalpenguin.com/opg/service/customer_care_returns_exchanges.jsphandling"
} 
if {[HTTP::host] contains "staging.originalpenguin.com" and [HTTP::uri] starts_with "/opg"}{
  use pool pei_staging_1080_pool
} else { 
  HTTP::redirect "http://staging.originalpenguin.com/opg/" 
}
}

Looking closely at the conditions you’ve created, there are 3 separate “if” statements, and there are indeed 2 redirects if a condition matches in one of the first 2 and you fall out to the “else” in the third.

I’d recommend changing the 2nd and 3rd "if"s to "elseif"s, and it is a good practice to add a “return” after each redirect to terminate rule processing for that connection. (Rule processing otherwise continues to evaluate all conditions to the end of each event.):

when HTTP_REQUEST {
if {[HTTP::host] contains "staging.originalpenguin.com" and [HTTP::uri] contains "/fif="}{
  use pool pei_staging_8087_pool
} elseif {[HTTP::uri] contains "user" or [HTTP::uri] contains "checkout" }{
  HTTP::redirect "https://[HTTP::host][HTTP::uri]"
  return 
} elseif {[HTTP::host] contains "staging.originalpenguin.com" and [HTTP::uri] starts_with "/dialogcentral"}{
  use pool pei_staging_1080_pool
} elseif {[HTTP::host] contains "staging.originalpenguin.com" and [HTTP::uri] starts_with "/returns.jsp"}{
...

HTH

/deb