# Condition with path\_reg and map\_reg with regexp

**URL:** <https://discourse.haproxy.org/t/condition-with-path-reg-and-map-reg-with-regexp/5565>\
**Category:** Help!\
**Created:** [August 5, 2020, 9:45pm UTC](https://discourse.haproxy.org/t/condition-with-path-reg-and-map-reg-with-regexp/5565 "2020-08-05T21:45:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbrahy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/jbrahy/32/525_2.png) [@jbrahy](https://discourse.haproxy.org/u/jbrahy)\
**Post date:** [August 5, 2020, 9:45pm UTC](https://discourse.haproxy.org/t/condition-with-path-reg-and-map-reg-with-regexp/5565/1 "2020-08-05T21:45:33Z")

</div>

Currently, I have a bunch of rules in haproxy.cfg like this:

frontend frontend-https  
bind 10.30.1.120:443  
redirect prefix [http://customerwebapp.com/redir.jsp?customer\_domain\_id=123](http://customerwebapp.com/redir.jsp?customer_domain_id=123) code 301 if { hdr(host) -m sub [example.com](http://example.com)  
}  
default\_backend backend-https

but I want to integrate a map file and take all the rules sets out with something like this:

frontend frontend-https  
bind 10.30.1.120:443  
redirect prefix (%[req.hdr(host),lower,map\_reg(/etc/haproxy/redirect.map)] code 301

}  
default\_backend backend-http

and the file would contain something like this  
(\w._.)?.customer.com(._) [https://webapp.com/redir.jsp?customer\_domain\_id=123](https://webapp.com/redir.jsp?customer_domain_id=123)

I know it’s missing the conditional, “if { hdr(host) -m sub [example.com](http://example.com)” but I’m not sure how to integrate them.

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [August 6, 2020, 12:05pm UTC](https://discourse.haproxy.org/t/condition-with-path-reg-and-map-reg-with-regexp/5565/2 "2020-08-06T12:05:48Z")

</div>

`https://webapp.com/redir.jsp?customer_domain_id=123` is not really a prefix, I assume you are going to use the correct redirect keyword in your real configuration.

You need to work with `http-request redirect` here instead.

Something like:

```
http-request redirect location %[req.hdr(host),lower,map_reg(/etc/haproxy/redirect.map)]
```

---

<div class="post-metadata">

**Author:** ![jbrahy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/jbrahy/32/525_2.png) [@jbrahy](https://discourse.haproxy.org/u/jbrahy)\
**Post date:** [August 6, 2020, 3:08pm UTC](https://discourse.haproxy.org/t/condition-with-path-reg-and-map-reg-with-regexp/5565/3 "2020-08-06T15:08:26Z")

</div>

Thank you so much, Lukas!
