Getting Apache virtual hosting working with Plone
December 9th, 2004
I've just spent the last couple of hours faffing around trying to get virtual hosting working for my Plone site (which will eventually replace the current incarnation of www.itauthor.com).
www.zopewiki.org/ZopeAndApache gives the best explanation I could find of how to set things up, using a RewriteRule in Apache's httpd.conf file. However, neither the instructions there, nor in Andy McKay's Definitive Guide to Plone (which I recently bought, and which seems to be a bit of a curate's egg) gave the instructions I needed to get things working.
Both sources say to use something along the lines of:
(Note: RewriteRule is split between 3 lines here, for readability. In reality it's one very long line.)
<VirtualHost *>
ServerName www.itauthor.com
RewriteEngine On
RewriteRule ^/(.*)
http://localhost:8080/VirtualHostBase/http/www.
itauthor.com:80/plone/VirtualHostRoot/$1 [L,P]
</VirtualHost>
When what I really needed was:
<VirtualHost *>
ServerName www.itauthor.com
RewriteEngine On
RewriteRule ^/plone(.*)
http://localhost:8080/VirtualHostBase/http/www.
itauthor.com:80/VirtualHostRoot/plone/$1 [L,P]
</VirtualHost>
Note the subtle differences with "plone" in the RewriteRule.
After lots of trial and error and Holmesian deduction of how RewriteRule worked, I finally figured out the solution and it now works fine - so I can go to bed!
One point worth noting, however - something that isn't spelled out in the McKay book or anywhere else I looked - is that the VirtualHost element, i.e.
<VirtualHost *>
...
</VirtualHost>
may already have other stuff in it (it will if, like me, you've just installed Fedora Core 3).
Rather than writing a new VirtualHost element, you just add the ServerName, RewriteEngine and RewriteRule attributes to the existing element. My VirtualHost element already had ServerSignature, DirectoryIndex, LogLevel and HostNameLookups attributes. Once I'd figured out that you didn't need a new VirtualHost element, I just added the rewrite attributes underneath the existing attributes.
##################
Correction
##################
I found out a couple of months after writing this that the rewrite rule in here was wrong.
See www.itauthor.com/notes/archives/2005/02/plone_urls_with.html for details.
Potentially similar posts
- It’s got to be fun – May 2011
- YOURLS: Your Own URL Shortener – October 2010
- ITauthor podcast #35 – On Crammond Island, thinking about technical writing – September 2010
- EasyListener resurrected – June 2010
- Articles – November 2008