Forum Discussion
Simple URL redirect iRule
A very basic (host-agnostic) redirect iRule might look something like this (applied to the port 80 VIP):
when HTTP_REQUEST {
HTTP::redirect "https://www.def.123.com[HTTP::uri]"
}
Where [HTTP::uri] is the URI from the original request (if you need to keep that). This will take any request to the VIP and (blindly) redirect it. Or do you only need it to redirect if the requested host value is "abc.com" or "www.abc.com"?
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] ends_with ".abc.com" } {
HTTP::redirect "https://www.def.123.com[HTTP::uri]"
}
}
If this VIP services a single (DNS) resolved host name, then all requests should technically be for abc.com or www.abc.com, and you could skip the HTTP::host evaluation.
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
