betabug... Sascha Welter

home english | home deutsch | Site Map | Sascha | Kontakt | Pro | Weblog | Wiki

05 September 2006

Rewriting All... but a few

More Zope RewriteRule fun

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/%{SERVER_NAME}:80/VirtualHostRoot/ [L,P]

RewriteRule ^/(.*) \\
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/%{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:

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.

Posted by betabug at 09:24 | Comments (2) | Trackbacks (0)
ch athens
Life in Athens (Greece) for a foreigner from the other side of the mountains. And with an interest in digital life and the feeling of change in a big city. Multilingual English - German - Greek.
Main blog page
Recent Entries
Best of
Some of the most sought after posts, judging from access logs and search engine queries.

Apple & Macintosh:
Security & Privacy:
Misc technical:
Athens for tourists and visitors:
Life in general:
<< Familien-Besuch | Main | Drinking with the Phrench >>
Re: Rewriting All... but a few

I have a similar situation where Zope serves up most content, except for subdomains prefixing the same domain. All the Virtual hosts are set up correctly, since I tested with regular document roots, but I can't get the rewriting to work within the single zope virtual host (single plone site).

I'm trying to serve up the plone site which works correctly, except to have it be referenced by users as simply

My rewrite lines are:

RewriteCond %{REQUEST_URI} !^/(stats|manual|static_images)

RewriteRule ^(.*) \\
http/%{SERVER_NAME}:80/1/VirtualHostRoot$1 [L,P]

Do I have something wrong here. Not sure if the Condition is even necessary... Thanks in advance for any insight. -Eric

Posted by: Eric Jahn at October 13,2006 19:50
Re: Rewriting All... but a few

Eric, you are a bit mistaken. First of all, using subdomains and separate VirtualHosts does not bother RewriteRules at all, in fact has nothing to do with them, as the RewriteRule will not take the hostname part into consideration. So your case doesn't really have anything to do with the one described here.

Second, if you needed to exclude some directories, you would know that. I bet you don't need that RewriteCond line.

As for why the rule you have doesn't work exactly right... I stopped debugging RewriteRules. Please just go over to the witch and get yourself a set of proper RewriteRules. If you still have problems, the Zope and Apache page on zopewiki has a "Problems" section that might help!

Best wishes to the dog! He looks like he's really having fun in that garden/forrest/green-whatever picture on his page.

Posted by: betabug at October 14,2006 11:21
You can trackback to:
There are no trackbacks.
Leave a comment