stecog
stecog

Reputation: 2344

haproxy - URL redirect with same path

i need redirect http://example1.com/goofy in http://example2.com/goofy, I already use this line:

redirect location http://example2.com code 301 if { hdr(host) -i example1.com }

In this way if I go on http://example1.com/goofy I am redirect to http://example2.com and not http://example2.com/goofy, can anyone help me?

Thanks

Upvotes: 0

Views: 647

Answers (1)

tbielaszewski
tbielaszewski

Reputation: 1084

Using pathq fetch from haproxy 2.2 will do this nicely:

redirect location http://example2.com%[pathq] code 301 if { hdr(host) -i example1.com }

https://cbonte.github.io/haproxy-dconv/2.2/configuration.html#7.3.6-pathq

Upvotes: 1

Related Questions