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

At present I am redirecting all http urls to https urls using the following directive,

RedirectMatch permanent ^(.*)$$1

Now I am stuck with an scenario where I have to redirect everything except the URLs like or or basically anything that has a /test followed by anything in it.

Also, I want to redirect these urls that have a "/test.." to be a normal http to show an access denied page(a html page). To add on to the complication all requests that go through "/" are routed to tomcat via ajp using the <Location /> and ProxyPass directives

I am forced to use only RedirectMatch in this case basically because if I have to use Rewrite I have to change a lot of other configurations.

Could we have multiple RedirectMatch? If so, how can I configure the regex for the scenario above...

share|improve this question

Use negative lookahead:

RedirectMatch permanent (^((?!test).)*)$$1
share|improve this answer
The redirect of URLs that does not have "test" in it results in 404..I guess the redirect isn't working properly... – Abhishek Mar 22 '12 at 1:40
try this ^(((?!test).)*)$ result of this redirection is: =, = – yadaya Mar 22 '12 at 6:45
I think what I would want is - everything that does not match or somesite/test.... followed by anything to be redirected to their https equvalents(eg somesite/nontest to somesite/nontest..) – Abhishek Mar 22 '12 at 7:26

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.