Forum Discussion
Kai_Wilke
Sep 16, 2016MVP
Hi Diez,
actually you've already answered your question yourself... 🙂
if a request for
http(s)://mail.acme.com/mail
is received and the ruleset contains those two [if]
conditions...
if { [HTTP::uri] starts_with "/mail" } then {
HTTP::redirect https://usa.acme/webmail_exchange
}
if { [HTTP::host] equals "mail.acme.com" } then {
HTTP::redirect https://mail.acme.com/webmail_zimbra
}
... then you would send two redirects for the very same request. This will result in an iRule exception (keep an eeye on your LTM logfile) and terminate the TCP connection before the redirect is send.
To solve your problem you could either issue a
return
command after each single HTTP::redirect
/ HTTP::respond
command to stop the processing of the current iRule...
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/test" } then {
HTTP::redirect "https://usa.acme.com/something"
return
}
if { [HTTP::uri] starts_with "/mail" } then {
HTTP::redirect "https://usa.acme/webmail_exchange"
return
}
if { [HTTP::host] equals "acme.com" } then {
HTTP::redirect "https://usa.acme.com"
return
}
if { [HTTP::host] equals "mail.acme.com" } then {
HTTP::redirect "https://mail.acme.com/webmail_zimbra"
return
}
}
... or by creating an collision free rule set...
when HTTP_REQUEST {
if { [HTTP::host] equals "acme.com" } then {
if { [HTTP::uri] starts_with "/test" } then {
HTTP::redirect "https://usa.acme.com/something"
} elseif { [HTTP::uri] starts_with "/mail" } then {
HTTP::redirect "https://usa.acme/webmail_exchange"
} else {
HTTP::redirect "https://usa.acme.com"
}
} elseif { [HTTP::host] equals "mail.acme.com" } then {
if { [HTTP::uri] starts_with "/test" } then {
HTTP::redirect "https://usa.acme.com/something"
} elseif { [HTTP::uri] starts_with "/mail" } then {
HTTP::redirect "https://usa.acme/webmail_exchange"
} else {
HTTP::redirect "https://mail.acme.com/webmail_zimbra"
}
}
}
Cheers, Kai