February 7th, 2005
I've been chewing this one over for a few weeks now, prodding the Internet for answers whenever I get a spare half hour or so - with no luck, until this evening.
I repeatedly skimmed back and forth through Andy McKay's Definitive Guide to Plone for the answer, but came up with nothing. But eventually I decided to read through Chapter 10 "Integrating with Other Systems" carefully, and this led me to the answer.
Actually, I didn't figure out what I'd been doing wrong from Andy McKay's book (although the answer is in there). In fact, I read through the stuff about creating a Virtual Host Monster to the point where he says "At this point, if you're using a proxy Web server in fron of Plone continue the configuration for that Web server in the 'Configuring the Proxy Server' section." I then decided to take a look at my own VHM.
I discovered that, if you have already created a VHM and, in the Zope Management Interface, you click Root Folder > Virtual Host Monster, you get a helpful "About" page that told me all I needed to know. I quote:
The most common sort of virtual hosting setup is one in which you create a Folder in your Zope root for each domain that you want to serve. For instance http://www.buystuff.com is served from Folder /buystuff.com while http://www.mycause.org is served from /mycause.org.
A single Virtual Host Monster in your Zope root can handle all of your virtual hosting needs. It doesn't matter what Id you give it, as long as nothing else in your site has the same Id.
The VHM doesn't do anything unless it sees one of the following special path elements in a URL: VirtualHostBase sets the protocol and host, while VirtualHostRoot sets the path root.
If the URL path of a request begins with "/VirtualHostBase/http/www.buystuff.com", for instance, then URLs generated by Zope will start with http://www.buystuff.com. Since the port number was not specified, it is left unchanged. If your Zope is running on port 8080, and you want generated URLs not to include this port number, you must use "/VirtualHostBase/http/www.buystuff.com:80".
If the URL contains VirtualHostRoot, then all path elements up to that point are removed from generated URLs. For instance, a request with path "/a/b/c/VirtualHostRoot/d" will traverse "a/b/c/d" and then generate a URL with path /d.
Visitors to your site don't see these special names, of course. You insert them into the path using either an external rewriter, such as an Apache RewriteRule or ProxyPass directive, or by setting up a mapping on the "Mappings" tab.
For example, suppose Zope is running on port 8080 behind an Apache running on port 80. You place a Virtual Host Monster in the Zope root Folder, and use Apache to rewrite "/(.*)" to http://localhost:8080/VirtualHostBase/http/www.buystuff.
com:80/buystuff.com/VirtualHostRoot/$1.
(Note: this is one long line.)
You could get the same effect in a standalone Zope by adding the line www.buystuff.com/buystuff.com to the "Mappings" tab. In either case, requests for http://www.buystuff.com/anything will look for Zope object /buystuff.com/anything.
A quick look in my httpd.conf file and it became clear what my problem had been. I had:
RewriteRule ^(.*) http://localhost:8080/VirtualHostBase/http/www.itauthor.com:80/
VirtualHostRoot/plone$1 [L,P]
When I should have had:
RewriteRule ^/(.*) http://localhost:8080/VirtualHostBase/http/www.itauthor.com:80/
plone/VirtualHostRoot/$1 [L,P]
plone was in the wrong place!
Read the rest of this entry »
Potentially similar posts