# Replace path not working

**URL:** <https://discourse.haproxy.org/t/replace-path-not-working/8802>\
**Category:** Help!\
**Created:** [June 27, 2023, 10:45am UTC](https://discourse.haproxy.org/t/replace-path-not-working/8802 "2023-06-27T10:45:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![igor](https://avatars.discourse-cdn.com/v4/letter/i/dec6dc/32.png) [@igor](https://discourse.haproxy.org/u/igor)\
**Post date:** [June 27, 2023, 10:45am UTC](https://discourse.haproxy.org/t/replace-path-not-working/8802/1 "2023-06-27T10:45:25Z")

</div>

Hi,

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 [api.back.server.com](http://api.back.server.com)  
http-request replace-path /pathv2 /v1

server back1 [api.back.server.com:443](http://api.back.server.com:443) ssl check cookie s1 sni req.hdr(Host) verify none

The problem is when I open the URL from browser:

[https://www.domain1.com/pathv2/session/login/action](https://www.domain1.com/pathv2/session/login/action)

It gets rewritten into:

[https://api.back.server.com/pathv2/session/login/action](https://api.back.server.com/pathv2/session/login/action)

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)]”

---

<div class="post-metadata">

**Author:** ![MaEh86](https://avatars.discourse-cdn.com/v4/letter/m/85e7bf/32.png) [@MaEh86](https://discourse.haproxy.org/u/MaEh86)\
**Post date:** [June 27, 2023, 2:05pm UTC](https://discourse.haproxy.org/t/replace-path-not-working/8802/2 "2023-06-27T14:05:07Z")

</div>

please try:

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

```

[https://cbonte.github.io/haproxy-dconv/2.2/configuration.html#http-request%20replace-path](https://cbonte.github.io/haproxy-dconv/2.2/configuration.html#http-request%20replace-path)

best regards,  
Markus
