Rewriting All... but a few
The RewriteRule Witch has eliminated a lot of questions about "apache and zope" on the #zope channel. One use case is not really covered yet though: The case where one wants to host everything in Zope, except for a few directories. This is easy to do though...
First step: We get a simple RewriteRule from the witch. We pretend for these examples that Zope serves internally on port 8080. This rule rewrites all requests to Zope:
RewriteRule ^$ \
http://127.0.0.1:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/VirtualHostRoot/ [L,P]
RewriteRule ^/(.*) \
http://127.0.0.1:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/VirtualHostRoot/$1 [L,P]
In its current incarnation the witch produces a rule which is doing too
much (it's not doing any harm though). I'll likely update the witch for
this special case Real Soon Now(TM). But for the moment, it can be
shortened to this one line:
RewriteRule ^(.*) \
http://127.0.0.1:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/VirtualHostRoot$1 [L,P]
Second step: Exclude access to some top-level directories (and their content), as these will be served by apache:
RewriteCond %{REQUEST_URI} !^/(stats|manual)
This is really childs play, but if you haven't been brought up with
regular expressions instead of mothers milk, you might want a closer
look. What do we have here in detail:
- ! <- we start with a "bang", so the following rewriterule is executed when the condition is *not* met.
- ^ <- our regex has to match at the start of the line
- / <- there has to be a slash in any case
- (stats|manual) <- a "group", which matches either "stats" or "manual". We could add other directories here, separated by "|".
- <- we don't have a "$" at the end, since that would mean that the line would have to end there. We don't want the line to end there, since we want this to apply to content inside those folders too.
Put the RewriteCond line in front of the RewriteRule and Apache will happily hand off everything but these directories to Zope to serve. The opposite case (only a few directories handled by Zope, everything else by Apache aka "inside out hosting") is covered well in the witch.