# Migrate Apache RewriteRule to haproxy http-request redirect

**URL:** <https://discourse.haproxy.org/t/migrate-apache-rewriterule-to-haproxy-http-request-redirect/3193>\
**Category:** Help!\
**Created:** [November 7, 2018, 1:22pm UTC](https://discourse.haproxy.org/t/migrate-apache-rewriterule-to-haproxy-http-request-redirect/3193 "2018-11-07T13:22:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ARadauer](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@ARadauer](https://discourse.haproxy.org/u/ARadauer)\
**Post date:** [November 7, 2018, 1:22pm UTC](https://discourse.haproxy.org/t/migrate-apache-rewriterule-to-haproxy-http-request-redirect/3193/1 "2018-11-07T13:22:09Z")

</div>

We have a lot RewriteRules in our Apache config files. Now we have to migrate these rules to haproxy.

For Example:

> RewriteCond %{HTTP\_HOST} ^app.mydomain. com\*  
> RewriteRule ^/$ app.mydomain. com/app/startpath [R,L]

How could this be configured in haproxy? like this?

> http-request redirect code 302 location [https://app.mydomain](https://app.mydomain). com/appPath if { path / and url\_dom app.mydomain. com }

Can I use values from a regex expression in the location?

We have a lot of these rules:

> RewriteRule ^/?products/(detail|edit)/(\S+)$ /p?$1=$2 [R=301,L]

where app.mydomain. com/products/detail/123 redirects to app.mydomain. com/p?detail=123

Can this be done in haproxy?

Thank you for your help

(the blank before the .com is because i’m getting the message “Sorry, new users can only put 2 links in a post.”)
