Use haproxy to redirect *.domain1.com/* to *.domain2.com/*
<p>I am struggling with some HAproxy rules for a while with no luck unfortunately. </p>

<p>Let's say I have domain1.com and domain2.com. I want to redirect everything from domain1.com to domain2.com, including subdomains and parameters.</p>

<p>Ex:</p>

<ul>
<li>foo.domain1.com => foo.domain2.com</li>
<li>foo.domain1.com/?bar => foo.domain2.com/?bar</li>
<li>domain1.com/?bar => domain2.com/?bar</li>
<li>etc</li>
</ul>

<p>I've tried with <code>reqrep ^([^\ ]*\) (.*)domain1.com(.*) 1/ domain2.com\2</code> but it does not do the trick.</p>

<p>Any ideas?</p>