Replace path not working


On haproxy version HA-Proxy version 2.2.20-1ppa1~bionic 2022/01/12 , (Ubuntu 18.04.3 LTS) we are trying to rewrite a complete request so that we can hit the backend server.

http-request set-header Host
http-request replace-path /pathv2 /v1

server back1 ssl check cookie s1 sni req.hdr(Host) verify none

The problem is when I open the URL from browser:

It gets rewritten into:

The /pathv2 isn’t changed and it should be. Any idea why?

I have also tried with regsub but it’s the same:
http-request set-path “%[path,regsub(^/pathv2,/v1,i)]”

please try:

http-request replace-path /pathv2/(.*) /v1\1

best regards,