URL path Redirection in Haproxy.cfg

haproxy

I have

https://www.mysites/v1/pages

and I want that to redirect to

https://www.mysites/v2/pages

I have added the following config on HAproxy config but not forward.

redirect location https://www.mysites/v2/pages 302 if { hdr(Host) mysites/v1/pages }

did I miss anything?

thanks.

Best Answer

Reading the documentation for the redirect statement makes me believe that part is correct (depending on where you put the statement).

Your ACL however doesn't seem to be correct. You filter on the host header (being www.mysites) while you should match on URI or path:

redirect location https://www.mysites/v2/pages 302 if { path_beg /mysites/v1/pages }
Related Topic