in reply to apache RedirectMatch (regexp question)
Hi
Apache processes the RedirectMatch statements from the top of the config file, to the bottom, so the 1st rule is matched first, 2nd rule second, etc, etc (as I'm sure you know).
What this means is that you can add all of your exceptions *above* your original regex, and they will get matched first. Unfortunately, you also need some way of stopping the rules matching again, after the redirect has been followed. This is why I have used the double '//' in the URLs (this does mean that exceptions will look ugly once the redirect has been followed). e.g.
RedirectMatch ^/basedirectory/exceptiondirectory1(.*)$ http://server1/ +basedirectory//exceptiondirectory1$1 RedirectMatch ^/basedirectory/exceptiondirectory2(.*)$ http://server1/ +basedirectory//exceptiondirectory2$1 RedirectMatch ^/basedirectory/(|[^/].*)$ http://server2/basedirectory/ +$1
This will work, but is a bit messy (and doesn't overly improve on your original suggestion).
What would be better is if the problem could be flipped, and you set the redirects up on server2 (but if you don't admin that server, I can see that would be a problem). Then all you would need is:
RedirectMatch ^/basedirectory/exceptiondirectory1(.*)$ http://server1/ +basedirdirectory/exceptiondirectory1$1 RedirectMatch ^/basedirectory/exceptiondirectory2(.*)$ http://server1/ +basedirectory/exceptiondirectory2$1
HTH,
-- Dave :-)
|
|---|