Haproxy url rewrite and masking

Hi All

I have a scenario here, I want to to redirect my frontend acl path_reg /foo/* to /bar/* but the /foo in the browser should not change

frontend test *:80

    acl testfoo          path_reg      /test/foo/*
   use_backend    foobackend   if testfoo

I want to rewrite the /test/foo to /newtest/foo and redirect to same foobackend, but the url in the browser should remain as /test/foo

I think the following should work:

reqrep ^([^\ :]*)\ /foo/(.*)     \1\ /bar/\2
reqrep ^([^\ :]*)\ /test/(.*)    \1\ /newtest/\2

Thanks for your reply, But am getting 404 error

i used your reqrep in the backend

reqrep ^([^\ :])\ /test/(.) \1\ /newtest/\2

Then find out why, by checking your backend logs.

This configuration does exactly what you requested:

Client request:

GET /test/foo HTTP/1.1
Host: testhost
User-Agent: curl/7.48.0
Accept: /

Request recieved at the backend server from haproxy:

GET /newtest/foo HTTP/1.1
Host: testhost
User-Agent: curl/7.48.0
Accept: /
X-Forwarded-For: 10.0.0.4

Should i use both your reg expressions?
I used the second one alone

The second expression is to replace /test with /newtest, the first expression replaces /foo with /bar