# The 'reqrep' directive is deprecated in favor

**URL:** <https://discourse.haproxy.org/t/the-reqrep-directive-is-deprecated-in-favor/4492>\
**Category:** Help!\
**Created:** [November 8, 2019, 2:51pm UTC](https://discourse.haproxy.org/t/the-reqrep-directive-is-deprecated-in-favor/4492 "2019-11-08T14:51:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luigy](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@luigy](https://discourse.haproxy.org/u/luigy)\
**Post date:** [November 8, 2019, 2:51pm UTC](https://discourse.haproxy.org/t/the-reqrep-directive-is-deprecated-in-favor/4492/1 "2019-11-08T14:51:23Z")

</div>

Hi,

we are upgrading haproxy fleet from v1.8.22 to v2.0.8. In that process we saw lot of logging:  
`The 'reqrep' directive is deprecated in favor of 'http-request replace-uri' and 'http-request replace-header' and will be removed in next version.`

So we decided to ditch **reqrep** and in that process the same regex that was working with reqrep is not working with the **http-request replace-uri**. We got 501 not implemented on from our backend server. But on older version 1.8.22 it’s working as it should.

Example:

```
backend name:
    #reqrep ^([^\ :]*)\ /abc/(.*) \1\ /\2
     http-request replace-uri ^([^\ :]*)\ /abc/(.*) \1\ /\2
     server server_name A.B.C.D:PORT

```

What are we doing wrong?

---

<div class="post-metadata">

**Author:** ![jerome](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/jerome/32/984_2.png) [@jerome](https://discourse.haproxy.org/u/jerome)\
**Post date:** [November 10, 2019, 7:32am UTC](https://discourse.haproxy.org/t/the-reqrep-directive-is-deprecated-in-favor/4492/2 "2019-11-10T07:32:54Z")

</div>

You need to adapt your regex with replace-uri. your reqrep rule captured the method and the part of the path you wanted, you don’t match the method in http-request replace-uri, only uri.

`http-request replace-uri /abc/(.*) /\1`

---

<div class="post-metadata">

**Author:** ![luigy](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@luigy](https://discourse.haproxy.org/u/luigy)\
**Post date:** [November 11, 2019, 8:59am UTC](https://discourse.haproxy.org/t/the-reqrep-directive-is-deprecated-in-favor/4492/3 "2019-11-11T08:59:26Z")

</div>

Hi,

thanks for reply.

Is there a way to limit the replace-uri only from the begining of the uri? If I use it like this, it will replace all /abc/ and I want replace only on the beginning  
[https://www.example.com/abc/cde/xyz/abc](https://www.example.com/abc/cde/xyz/abc) -\> [https://www.example.com/cde/xyz/abc](https://www.example.com/cde/xyz/abc)

---

<div class="post-metadata">

**Author:** ![jerome](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/jerome/32/984_2.png) [@jerome](https://discourse.haproxy.org/u/jerome)\
**Post date:** [November 11, 2019, 10:53am UTC](https://discourse.haproxy.org/t/the-reqrep-directive-is-deprecated-in-favor/4492/4 "2019-11-11T10:53:15Z")

</div>

my bad, it should have been:  
`http-request replace-uri ^/abc/(.*) /\1`

---

<div class="post-metadata">

**Author:** ![luigy](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@luigy](https://discourse.haproxy.org/u/luigy)\
**Post date:** [November 11, 2019, 12:34pm UTC](https://discourse.haproxy.org/t/the-reqrep-directive-is-deprecated-in-favor/4492/5 "2019-11-11T12:34:16Z")

</div>

Jerome,

Thx for the help 🙂
