[Zope] Apache/VHM _and_ AccessRule at the same time

Danny W. Adair danny@adair.net
Mon, 16 Jun 2003 12:33:46 +1200


I'm running into some problems having Apache Rewrite -> Virtual Host 
Monster and an Access Rule _at the same time_.

The Access Rule (which extracts an embedded variable from the URL, similar 
to http://www.zope.org/Members/4am/SiteAccess2/otheruse ) works fine when I 
access the Zope Server directly through its IP.

The Apache Rewrite/VHM on the other hand works fine as long as I don't 
access the folder holding the Access Rule. So I assumed both individual 
settings were alright (see below).

But as soon as I access _that_ folder through a domain, I get very weird 
URLs generated on my pages (which don't work of course): The 
VirtualHostBase is _not_ removed, and a "/VHost//" is added after it. I'm 
not sure how to handle this.

Here's my configuration:

<VirtualHost admin.mydomain.com:80>
RewriteEngine On
ProxyRequests On

CustomLog /cms/Zope/log/zope_access_log combined
ErrorLog /cms/Zope/log/zope_error_log
RewriteLog /cms/Zope/log/zope_rewrite_log
RewriteLogLevel 9

RewriteRule ^/statistics(.*)/ - [L]
RewriteRule ^/(.*) 

/VHost (Virtual Host Monster)
                                     /extractCustomerFromURL (AccessRule)

Access Rule "extractCustomerFromURL"
request = container.REQUEST
stack = request['TraversalRequestNameStack']
customer_id = stack.pop()
request.set('customer_id', customer_id)
request.setVirtualRoot(request.steps + [customer_id])

So "/Customers/mycustomer/Subfolder/x" should call "/Customers/Subfolder/x" 
and set "customer_id" to "mycustomer" in the REQUEST object. 
"/Customers/Subfolder/x" then uses that customer_id to show corresponding 

If I go to 
it works, and if I go (no further down than) "admin.mydomain.com/x", 
everything's fine as well.

But "admin.mydomain.com/Customers/mycustomer" (and of course anything 
further down, i.e. .../Subfolder/x) don't work as expected.

For example a link to the subfolder .../Accounts/hisaccount (which I build 
with container['Accounts'].absolute_url() + '/hisaccount') will come out as:


The domain is kept, but the VirtualHostRoot /Interfaces/InterfaceAdmin 
remains, and "/VHost//" is appended to it. (A REQUEST dump said exactly 
that same thing...)

Does anyone have an idea on how to solve this?
What exactly is "Virtual Host Monster" (yes the VHM in the Zope root has 
the id "VHost" :-)) doing to the virtual root and how can I work with it as 

Ideally, a solution would work both ways - IP and domain-based. But I'm 
ready to sacrifice the IP-based access if only the domain rewriting would 
work with my Access Rule... :-(

Any help highly appreciated,
thank you very much in advance,


P.S.: Please "Reply All" to include my address since I am currently not a 
subscriber of zope@zope.org... Cheers.