# Trouble creating rewrite rule

**URL:** <https://discourse.haproxy.org/t/trouble-creating-rewrite-rule/2869>\
**Category:** Help!\
**Created:** [August 17, 2018, 3:29pm UTC](https://discourse.haproxy.org/t/trouble-creating-rewrite-rule/2869 "2018-08-17T15:29:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blans](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/blans/32/575_2.png) [@blans](https://discourse.haproxy.org/u/blans)\
**Post date:** [August 17, 2018, 3:29pm UTC](https://discourse.haproxy.org/t/trouble-creating-rewrite-rule/2869/1 "2018-08-17T15:29:58Z")

</div>

Hi Guys,  
I’m trying to convert a Rewrite Rule from httpd to haproxy, and can’t firue out a solution, maybe somebody here can halp me?

The Rule looks like that:  
RewriteCond %{REQUEST\_FILENAME} “.\*/foo\_.\*”  
RewriteRule ^(.\*)/foo\_(.\*)$ [https://www.otherhost.de/foo$1/$2](https://www.otherhost.de/foo%241/%242) [NC,L,R=301]

It basically changes

[https://www.host.de/bla/foo\_blablub](https://www.host.de/bla/foo_blablub)  
to  
[https://www.otherhost.de/foo/bla/blablub](https://www.otherhost.de/foo/bla/blablub)

I’ve been experimenting with reqrep, but no success so far.
