Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to rewrite a URI as well as a host header based on some conditions. Here is an example of what I'm trying to accomplish:

I request

if hdr_beg(Host) and path_beg /test
    rewrite host header to
    rewrite URI to /files/other (in other words, remove test from the URI)

The end result should point to without the user being aware.

I have tried the following configuration:

acl host_beg_sub1 hdr_beg(Host)
acl path_beg_test path_beg /test
rewrite host header if host_beg_sub1 path_beg_test
rewrite URI if host_beg_sub1 path_beg_test

Obviously, this doesn't work as expected since the second rewrite won't fire after the host header has been modified.

I cannot rewrite without a condition since there is other traffic whose URI might begin with test.

Thanks in advance!

share|improve this question

If you want to make a bunch of replacements, you might want to consider putting them in a backend.

    acl host_beg_sub1 hdr_beg(Host)
    acl path_beg_test path_beg /test
    use_backend sub2redirect if host_beg_sub1 path_beg_test 

    reqirep ^Host:\   Host:\
    reqirep ...url rewriting 
    server ...
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.