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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access