1

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

RedirectMatch permanent ^(.*)$ https://someserver.com$1

Now I am stuck with an scenario where I have to redirect everything except the URLs like http://someserver.com/test or http://someserver.com/test/users 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...

1 Answer 1

1

Use negative lookahead:

RedirectMatch permanent (^((?!test).)*)$  https://someserver.com$1
3
  • 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, 2012 at 1:40
  • 2
    try this ^(((?!test).)*)$ result of this redirection is: somesite.com/test/me = somesite.com/test/me, somesite.com/folder/me = anothersite.com/somesite.com/niodest/me
    – yadaya
    Mar 22, 2012 at 6:45
  • I think what I would want is - everything that does not match somesite.com/test or somesite/test.... followed by anything to be redirected to their https equvalents(eg somesite/nontest to somesite/nontest..)
    – Abhishek
    Mar 22, 2012 at 7:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .