Plone URLs without the Plone site ID

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! This highlights a problem with Andy Mckay's book. Okay, if I'd read it more carefully I wouldn't have made this mistake. But the fact is that, despite owning this book, I worked out the necessary rewrite rules from my own Internet research. So: a) Something about the book meant I couldn't find out how to do this using the book - although the information *was* in there. b) Having made a mistake, I couldn't easily find the solution in the book. The obvious answer is that the index is not up to scratch. But I think there's more to it than that. I think there's a problem with the structure of Andy McKay's book - at least for me. Because what I wanted to do with Plone was install it and quickly customize it to look and behave according to my particular requirements. Installing Plone was a problem on Fedora Core 3, and I had to delve deeply into obscure Internet sources to sort out the dependency problems Fedora threw up during installation. This wasn't the book's problem, but the fact that the book wasn't helpful here caused my first doubts about its reliability. Having got Plone working I wanted to start customizing it. However, Andy McKay's book goes from installation to a sort of simple guide for contributor-only users. It's as if that bit of the book is written for someone else than the rest of the book. Personally, at that stage I didn't want to start adding content. I wanted to configure it first, so I skipped ahead. And as soon as readers start skipping ahead you'd better have a book that is robustly unreliant on being read sequentially. I don't think this book is. I think it suffers from the same problem a lot of software books are afflicted with. It tells you lots of things about the software - lots of things the software does - but doesn't arrange this information into topics that tell you how to achieve particular tasks. So, for example, opening up the book in the middle, we have the following headers in a chapter on setting up users: User Registration Tools Portal Registration Portal Member Data Portal Membership Useful APIs Cookie Authentication The Actual User Folder None of these section headings leap out at me as "Here's something you want to do" or "How to do X". Okay, so I spend much of my time writing Online Help, which is very topic-oriented, but I really don't have the time or inclination to read an application manual from A to Z. I want to read the first chapter, then dip in and out as I use the software. However, I don't think it's a bad book. If I had a PDF of it that I could search through (i.e. in the absense of a good index) I think the book would be extremely useful. While looking for Plone info I discovered that the book is available online at: www.jazkarta.com/technology/plone/plonebook, so perhaps I'll use that in future, rather than my printed copy. Jazkarta is quite a nice example of a Plone site. Other sites I've come across are: http://plone.org/ - if you're into Plone you'll have been here already http://www.isradiology.org/ - the International Society of Radiology http://www.maenner-club.de/ - "Mà¤nner-Club - home is where you hang your @" (a nice-looking German-language site) http://support.datasplice.com/ - The online support site for DataSplice mobile technology But my favourite Plone site is: http://scs.ictp.it/ Which is the Scientific Computer Section of the ICTP (the International Centre for Theoretical Physics) in Trieste in Italy. It's very well structured and looks beautiful (most of the work seems to be by Sabrina Visintin), and I'm going to be going back to look at the contents of this site in more detail, it has a lot of interesting-looking topics.

Potentially similar posts

Leave a comment