[Zope] Multiple virtual hosts and domains

Alex Gould agould@student.umass.edu
Sun, 18 Jun 2000 21:06:38 -0400


Hugo Ramos wrote:

> After testing SiteAccess for about 100 times... i still can't get zope to
> serve multiple virtual hosts and domains...
> I would like very much that someone with a successful siteaccess instalation
> in a real production site could get in touch with me and try to get this
> working.

I just recently asked this question and got it to work.  This setup
works if you have several subdomains 'sitea.domain.tld' and
'siteb.domain.tld' etc.  It may have to be modified to work with other
setups - don't ask me how!

-  create folders sitea, siteb, and so on in your root zodb directory
-  put a siteroot in each folder, leaving all fields except name blank
-  make a dtml method in the root directory called virtual_hosts or
something, consisting of the following script:
<dtml-comment>
Get subdomain:
</dtml-comment>
<dtml-let
hostname="_.string.join(_.string.split(_.string.split(HTTP_HOST,':')[0],
'.')[0], '')">
<dtml-comment>
Is there a folder named as this subdomain?
</dtml-comment>
  <dtml-try>
     <dtml-if "[hostname]">
        <dtml-comment>
	Set logical root: 
	</dtml-comment>
		<dtml-call "REQUEST.set('SiteRootPATH', '/')">
        <dtml-comment>
	Add physical root: 
	</dtml-comment>
		<dtml-call "REQUEST.path.append(hostname)">   
     </dtml-if>
   <dtml-except KeyError>
      <dtml-call
"RESPONSE.redirect('http://www.domain.tld/site_not_found')">
   </dtml-try>
</dtml-let>
-  Create a Site Access Rule in the root folder and have it call this
method.
This should work, but don't ask me how (credit goes to Ethan Mindlace
Freeman, who gave me these instructions).  Good luck!
-------------- 
Building highways to reduce traffic is like 
loosening your belt to reduce obesity.