Forum Discussion
wg
Nimbostratus
Feb 27, 2020irule redirect to new site for http and https traffic
I need to create an irule to redirect traffic to a new site for both http and https. My current rule is only working for http traffic, could use a hand on this as I don't have much experience with...
NAG
Cirrostratus
Feb 27, 2020Hi,
If you are handling both HTTP and HTTPS traffic, you should configure 2 Virtual servers. One listening on port 80 and the other listening on 443.
If you want to redirect on both http and https, you have apply iRule on both the Virtual Servers.
Here is are two examples::
For temporary redirect::
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains "/random/stuff" } {
HTTP::redirect "https://abc.mydomain.com[HTTP::uri]"
}
}For permanent redirect:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains "/random/stuff" } {
HTTP::respond 301 Location "https://abc.mydomain.com[HTTP::uri]"
}
}Hope this helps,
Nag
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