[Zope] virtual hosts with ZServer

ethan mindlace fremen mindlace@digicool.com
Tue, 13 Jun 2000 22:06:21 -0600


Alex Gould wrote:
> 
> My apologies if this question has been answered before, but I couldn't
> figure it out from available documentation or list archives.
> 
> I run a server for some student groups off a machine in my dorm and I'm
> teaching myself Zope (slowly).  I deal with the dynamic IP address by
> using several *.penguinpowered.com domains.  I would like to set up one
> or more virtual hosts such that http://host1.penguinpowered.com/ points
> to some folder in the Zope database.  It seems this is possible using
> Set Access Rule and SiteRoot objects, but how?  Any help is
> appreciated.  I am now using plain zserver 2.1.6.

I have answered this before :)

This is the access rule I use to match subdomains with a folder that has the
same name as the subdomain:

Get subdomain:
<dtml-let hostname="_.string.join(_.string.split(_.string.split(HTTP_HOST,
':')[0], '.')[0], '')">
Is there a folder named as this subdomain?
  <dtml-try>
     <dtml-if "_[hostname]">
        Set logical root: <dtml-call "REQUEST.set('SiteRootPATH', '/')">
        Add physical root: <dtml-call "REQUEST.path.append(hostname)">   
     </dtml-if>
   <dtml-except KeyError>
      <dtml-call "RESPONSE.redirect('http://penguinpowered.com/NoHostHere')">
   </dtml-try>
</dtml-let>

Then there has to be a site root in each folder, where the path and base are
*empty*.

Hope that helps,

ethan mindlace fremen
Zopatista Community Liason