Forum Discussion
spanudiez_29062
Nimbostratus
Sep 16, 2016Redirect HTTP::uri doesn't work properly.
Hi,
I have some issues with redirecting.
I have the following rules set up :
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/test" } {
HTTP::redirect https://usa.acme.com/...
Kai_Wilke
MVP
Sep 16, 2016Hi 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
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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