Examples
For simple name-based virtual hosts, you might use the following directives in your server-configuration file:
UseCanonicalName Off VirtualDocumentRoot /usr/local/apache/vhosts/%0
A request for http://www.example.com/directory/file.html will be satisfied by the file /usr/local/apache/vhosts/www.example.com/directory/file.html.
On .../site.dynamic we have implemented a version of the familiar Buttterthlies site, with a password-protected salesperson’s department. The first Config file, .../conf/httpd1.conf, is as follows:
User webuser Group webgroup ServerName my586 UseCanonicalName Off VirtualDocumentRoot /usr/www/APACHE3/site.dynamic/htdocs/%0 <Directory /usr/www/APACHE3/site.dynamic/htdocs/sales.butterthlies.com> AuthType Basic AuthName Darkness AuthUserFile /usr/www/APACHE3/ok_users/sales AuthGroupFile /usr/www/APACHE3/ok_users/groups Require group cleaners </Directory>
Launch it with go 1; it responds nicely to
http://www.butterthlies.com and
http://sales.butterthlies.com.
There is an equivalent VirtualScriptAlias
directive, but it insists on URLs containing ../cgi-bin/... — for instance,
www.butterthlies.com/cgi-bin/mycgi. In view of
the reputed horror some search engines have for
“cgi-bin”, you might prefer not to
use it and to keep “cgi-bin” out of
your URLs with this:
ScriptAliasMatch /(.*) /usr/www/APACHE3/cgi-bin/handler/$1
The effect should be that any visitor to <http://yourURL>/fredwill call the script .../cgi-bin/handler and pass “fred” to it in the PATH_INFO ...