Forum Discussion
redirect based on host and uri
I believe you can actually get what you need from the first iRule, but simply invert the cases, as in:
when HTTP_REQUEST {
if { [HTTP::uri] eq "/" } {
HTTP::redirect "https://newsite.com/identitymanagement/default.aspx"
} elseif { [string tolower [HTTP::host]] eq "oldsite.com" } {
HTTP::redirect "https://newsite.com[HTTP::uri]"
}
}
That way, if the request is "http[s]://oldsite.com/" or "http[s]://newsite.com/", the redirect will be to "https://newsite.com/identitymanagement/default.aspx". Otherwise, a redirect occurs if and only if the Host header is "oldsite.com". (Notice that I removed the
string tolower on the HTTP::uri verification, since it isn't needed for this comparison case).
Instead of using an iRule, however, you should consider employing Local Traffic Policies if you are using 11.4 or above, or HTTP Classes if you are using a version lower than that:
Generally, these mechanisms are more efficient than an iRule.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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