We use the following header rewrite rule:

reqirep ^([^\ ]*)\ /stats/(.*)  \1\ /cgi-bin/\2

This means the browser window says http://www.domain.com/stats/stats.cgi, but the backend server receives a request for www.domain.com/cgi-bin/stats.cgi

Would this not work as follows:

reqirep ^([^\ ]*)\ /(.*)/mypage  \1\ //\2/page

Note - I've not tested that so it may break stuff - check before running this.

Chris


Matt wrote:
Hi Willy, sure.

I guess what i'd be writing with my knowledge of haproxy at the moment
is one of these for every user:-

acl user1 url_beg /user1/mypage
redirect location http://mysite.com/user1/page code 301 if user1

It would be great if I could do:
acl user1 url_reg /(.*)/mypage
redirect location http://mysite.com/\1/page code 301 if user1

Prefix doesn't work in this context as the thing I want to change is
after the value i'm capturing.

I've tried to think about how I could do it with the reqrep and rsprep
but i'm finding it hard to get my head round.  Especially since I
really wouldn't like the request to hit a server when I want to
redirect them.

Any help appreciated.

Thanks,

Matt

2009/12/2 Willy Tarreau<[email protected]>:
Hi Matt,

On Wed, Dec 02, 2009 at 12:58:50PM +0000, Matt wrote:
I guess this can't be done at the moment? Is there a feature request
for this already?
(...)
RewriteRule ^/([a-z]+)/mypage$  http://mydomain.com/$1/yourpage [R=301,L,NE]

Sorry, but I'm unable to parse apache's cryptic rewriterules.
You're saying that you want to perform a redirect which keeps
some part of the request. Could you please post a concrete
example of what you'd have in the request and what you'd like
to see in the Location header ? There are some possibilities
with the redirect statement (prefix, etc...) but maybe not what
you're looking for. But maybe we can do it differently.

Regards,
Willy




Reply via email to