# Haproxy set variable value from map

**URL:** <https://discourse.haproxy.org/t/haproxy-set-variable-value-from-map/3745>\
**Category:** Help!\
**Created:** [April 19, 2019, 7:19pm UTC](https://discourse.haproxy.org/t/haproxy-set-variable-value-from-map/3745 "2019-04-19T19:19:24Z")\
**Posts on this page:** 1\
**Page:** 1

<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:** [April 19, 2019, 7:19pm UTC](https://discourse.haproxy.org/t/haproxy-set-variable-value-from-map/3745/1 "2019-04-19T19:19:24Z")

</div>

I am trying to set a variable value from map contents, base on the path.

```
 http-request set-var(req.prefdomain) %[path,map_beg(/etc/haproxy/haproxy_path_domain.map)]

```

here is my map content

```
 /abc/def/v1 domain1
 /ijk/lmn/v2 domain2

```

My use case if the path (/abc/def/v1) is configured (in map) to be served on `domain1` then i want to restrict the path on `domain2`. i was try to get the domain1 & domain2 in a custom variable. Using that variable to check the string match & handle routing or deny. Is there a way to get `domain1` to `prefdomain` variable? if so can you suggest the fix for the above http-request line.
