Forum Discussion
Brian_Kenworthy
Feb 10, 2011Nimbostratus
HTTP>HTTPS Redirect to different domain
Hi all, this should be pretty simple....hopefully.
I have a simple HTTP>HTTPS redirect in place for a domain --> HTTP::redirect "https://[HTTP::host][HTTP::uri]"
We have several subdomains (~15) xxx.domainA.com, yyy.domainA.com, etc. What we would like to do now is redirect those same sub domains to a new domain:
http://xxx.domainA.com to https://xxx.domainB.com
http://yyy.domainA.com to https://yyy.domainB.com
http://zzz.domainA.com to https://zzz.domainB.com
Is there any easier way to do this besides using a switch command for ever sub domain? I.E.
when HTTP_REQUEST {
switch [HTTP::host] {
xxx.domainA.com {
HTTP::redirect "https://xxx.domainB.com"
}
yyy.domainA.com {
HTTP::redirect "https://yyy.domainB.com"
}
etc...
Thanks in advance for the help!
- hooleylistCirrostratusSure, just add the domain suffix to the redirect:
when HTTP_REQUEST { if { [string tolower [HTTP::host]] ends_with "domaina.com" } { HTTP::redirect "https://[getfield [HTTP::host] "." 1].domainB.com.sg[HTTP::uri]" } }
- Narendra_DandekNimbostratusWhat if we have multiple prefix to the domain. whill that be reditected too. For example if we have xxx.yyy.DomainA.com this does not get routed to xxx.yyy.DomainB.com with the above rule. Am i missing anythin here.
- nitassEmployeee.g.
[root@ve10:Active] config b virtual bar list virtual bar { destination 172.28.19.79:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { set host [string tolower [HTTP::host]] if {$host ends_with "domaina.com"} { HTTP::redirect "https://[string map {"domaina.com" "domainb.com"} $host][HTTP::uri]" } } } [root@ve10:Active] config curl -I http://172.28.19.79/something -H "Host: www.domaina.com" HTTP/1.0 302 Found Location: https://www.domainb.com/something Server: BigIP Connection: Keep-Alive Content-Length: 0 [root@ve10:Active] config curl -I http://172.28.19.79/something -H "Host: xxx.yyy.domaina.com" HTTP/1.0 302 Found Location: https://xxx.yyy.domainb.com/something Server: BigIP Connection: Keep-Alive Content-Length: 0
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