A solution for virtual hosts and Rendezvous

Aug 23, '04 10:33:00AM

Contributed by: melo

A previous hint described how to use the RegisterResource feature of mod_apple_rendezvous to publish additional paths of your local server via Rendezvous. Virtual hosts are more complicated because you cannot send the hostname via Rendezvous, apparently. But that's easy to solve with mod_rewrite.

First, create a file (I named mine virtualhosts.conf), and place it in /etc -> httpd -> users. Place the following inside:

# you can put anything after /.vh/ as longs as
# it starts with the site name followed by an 
# optional path
RegisterResource "MacOS X Hints" /.vh/www.macosxhints.com/
RegisterResource "Send me one, please!" /.vh/www.apple.com/displays/
# Add other RegisterResource as above to add more sites

# Magic.....
RewriteEngine On
RewriteRule /\.vh/(.+) http://$1 [R]
Next, restart your Apache webserver:

$ sudo apachectl stop
$ sudo apachectl start
You can also restart with sudo apachectl restart or even sudo apachectl graceful. I prefer stop/start, though. That's it. Check your Rendezvous menu in the Bookmarks Bar in Safari, and you'll find a "MacOS X Hints" entry that will redirect to this site. We can also use this method to support HTTPS. Just add this line to the file:
RewriteRule /\.vhs/(.+) https://$1 [R]
And register resources as:

RegisterResource "Amazon" /.vhs/www.amazon.com/
We use a prefix, /.vh/ (and /.vhs/), that should be unused in most configurations. If you happen to use it in your own configuration, change all the occurrences to something else, like /.idontusethis/.

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040820173007718