0

I am trying to do some redirections with haproxy. I have 2 sites www.example.com and http://example.com

I want to redirect www.example.com to www2.example.com

But http://example.com should not be redirected, as it is being referenced by page.

How to do this with haproxy ?

Regards,

K

1 Answers1

1

Redirect based on Host header in HAProxy

If your goal is to redirect www.example.com to www2.example.com, then below is one way. 302 is temporary redirect, 301 is perm.

redirect prefix http://www2.example.com code 302 if { hdr(host) -i www.example.com }

Assuming you want to leave the apex (bare / naked) domain alone, the above should work.

Aaron
  • 2,859
  • 2
  • 12
  • 30