I am working with HAProxy and want to be able to redirect all traffic from domainA to a second domainB preserving the prefix/subdomain.
I have tried things like:
redirect prefix http://www.domainA.com code 301 if { hdr(host) -i http://www.domainB.com }
which works but I may have several other domains each having sub-domains.
I want to be able to do something like
redirect prefix http://*.domainA.com code 301 if { hdr(host) -i http://*.domainB.com }
redirect prefix http://*.domainA.com code 301 if { hdr(host) -i http://*.domainC.org }
Domains B & C are effectively aliases for domainA in this instance. Is there a way of doing this so I only need on entry per alias domain?
To further increase complexity I would ideally want to ignore what protocol the inbound request comes in (http
/https
) and redirect to https
For this instance I would be looking at doing something like
redirect prefix http://*.domainA.com code 301 if { hdr(host) -i (http|https)://*.domainB.com }
redirect prefix http://*.domainA.com code 301 if { hdr(host) -i (http|https)://*.domainC.org }