0

i need redirect request from specific domain/path to other domain with same path, eg.

domain.com/foo/everything --> example.com/foo/everything

I think need use url_reg but I can't understand how to handle the redirect, maybe it could be such a thing?

acl redirect-foo url_reg -i ^domain.com\/foo\/* http-request redirect code 301 location http://example.com/foo/ if redirect-foo 

but obviously it doesn't work, thank anyone who can help me

1 Answer 1

3

You can use the following snipplet

acl host_match hdr(host) -i domain.com acl path_match path_beg -i /foo/ http-request redirect code 301 location http://example.com/%[capture.req.uri] if host_match path_match 

The acl's are described in the Documentation and in following Blog post.

Using ACLs to form conditions
Introduction to HAProxy ACLs

Documentation for capture.req.uri

Sign up to request clarification or add additional context in comments.

2 Comments

If I would redirect without /foo/? ie domain.com/foo/everything --> example.com/everything
Then I would try %[capture.req.uri,regsub(/foo,)] Documentation for regsub

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.