Migrate Apache RewriteRule to haproxy http-request redirect

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. 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.”)