Forum Discussion
Redirect to different domain also force http to https
Hi guys,
I have three domains (a, b and c) and i want to redirect first two of them (a,b) to the last (c), also force http to https for all of them.
I put together below rule which works but I wonder how this can be simplified
this works for all cases except http://c
if { [HTTP::host] eq "a" or [HTTP::host] eq "b"} {
HTTP::redirect "https://c[HTTP::uri]"
return
}
this is to force http://c to https://c
elseif {([TCP::local_port] == 80) and [HTTP::host] equals"c"}{
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
return
}
Thank you
2 Replies
- Vijay_E
Cirrus
Are you using separate VS for port 80 and another VS for 443 ? If so, you can use something like this:
when HTTP_REQUEST { HTTP::redirect "https://c[HTTP::uri]" }I am assuming that VS1:80 is for handling the 3 domains ONLY i.e., no other domain relies on that VS1:80. If you have multiple domains relying on VS1:80, you can use something like this:
when HTTP_REQUEST { switch -glob [HTTP::host] { "a" - "b" - "c" { HTTP::redirect "https://c[HTTP::uri]" } }Although you end up with 2 VS, I think this is a cleaner way to configure the F5 and it effectively restricts access to port 80 & 443 on the VS.
- Stanislas_Piro2
Cumulonimbus
Hi,
irule provided by Odaah must not be enabled on HTTPS virtual server, if you enable it, browser will loop. yours manage tcp local port filter on c domain.
when HTTP_REQUEST { switch -glob [HTTP::host] { "a" - "b" { HTTP::redirect "https://c[HTTP::uri]" } "c" { if {[TCP::local_port] == 80} { HTTP::redirect "https://c[HTTP::uri]" } } } }
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
