How to redirect URL with HAProxy

后端 未结 1 1555
日久生厌
日久生厌 2021-02-07 07:02

I need redirect www.foo.com and foo.com to www.bar.com in haproxy, this is my configuration:

frontend  http-in
    bind *:80

    acl bar.com hdr(host) -i www.ba         


        
1条回答
  •  梦谈多话
    2021-02-07 08:03

    Change order of the hostname:

    redirect prefix http://www.bar.com code 301 if { hdr(host) -i foo.com }
    redirect prefix http://www.bar.com code 301 if { hdr(host) -i www.foo.com }
    

    instead of

    redirect prefix http://foo.com code 301 if { hdr(host) -i www.bar.com }
    redirect prefix http://www.foo.com code 301 if { hdr(host) -i www.bar.com }
    

    0 讨论(0)
提交回复
热议问题