# Multiple backend redirections

**URL:** <https://discourse.haproxy.org/t/multiple-backend-redirections/3435>\
**Category:** Help!\
**Created:** [January 27, 2019, 5:23pm UTC](https://discourse.haproxy.org/t/multiple-backend-redirections/3435 "2019-01-27T17:23:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rootfs](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@rootfs](https://discourse.haproxy.org/u/rootfs)\
**Post date:** [January 27, 2019, 5:23pm UTC](https://discourse.haproxy.org/t/multiple-backend-redirections/3435/1 "2019-01-27T17:23:06Z")

</div>

Hi  
I have some problem with backend redirection

Here is my configs  
frontend  
acl somesite-acl path\_sub /service/v2/amount/balance path\_sub /service/v2/amount/fund path\_sub /service/pg path\_sub /service/testing  
use\_backend be\_somesite if somesite-acl

backend be\_somesite  
http-request set-header Host [somesite.com](http://somesite.com)  
reqirep ^([^\ :]_)\ /(._) \1\ /service/v2/amount/\2  
reqirep ^([^\ :]_)\ /(._) \1\ /service/pg/\2  
reqirep ^([^\ :]\*)\ /testing \1\ /service/tested/\2  
server site\_node [somesite.com:443](http://somesite.com:443) cookie S2 cookie S2 check ssl verify none

Below is what I want to achieve

[example.com/service/v2/amount/balance](http://example.com/service/v2/amount/balance)  
[somesite.com/service/v2/amount/balance](http://somesite.com/service/v2/amount/balance)

[example.com/service/v2/amount/fund](http://example.com/service/v2/amount/fund)  
[somesite.com/service/v2/amount/fund](http://somesite.com/service/v2/amount/fund)

[example.com/service/pg](http://example.com/service/pg)  
[somesite.com/service/pg](http://somesite.com/service/pg)

[example.com/service/testing](http://example.com/service/testing)  
[somesite.com/service/tested](http://somesite.com/service/tested)

Can someone try to help as I am new to haproxy and I have been working from few days to fix this, but haven’t find any solution yet

---

<div class="post-metadata">

**Author:** ![ykiran\_k](https://avatars.discourse-cdn.com/v4/letter/y/ea666f/32.png) [@ykiran\_k](https://discourse.haproxy.org/u/ykiran_k)\
**Post date:** [January 31, 2019, 10:23pm UTC](https://discourse.haproxy.org/t/multiple-backend-redirections/3435/2 "2019-01-31T22:23:41Z")

</div>

try this…

```
 http-response redirect code 301 location somesite.com%[customHeader] unless { hdr_beg(host) -i example.com }

```

I got it from the example in the docs from this section - [https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4.2-redirect%20scheme](https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4.2-redirect%20scheme)

Since %[capture.req.uri] would not be available in backend, you have to store that value in a custom request header & read that value in backend section
