======================
Simple Virtual-Hosting
======================

------------------------
Module: mod_simple_vhost
------------------------

:Author: Jan Kneschke
:Date: $Date: 2004/08/29 09:43:49 $
:Revision: $Revision: 1.1 $

:abstract:
  virtual hosting
  
.. meta::
  :keywords: lighttpd, virtual hosting
  
.. contents:: Table of Contents

Description
===========

Simple assumption:

Every virtual host is in a direction below a base directory in a path that
is the same as the name of the vhost. Below this vhost-path might be a
extra directory which is the document-root of the vhost.

The document-root for each vhost is build from three values:

- server-root
- hostname
- document-root

Either the absolute documentroot is build by ::

  server-root + hostname + document-root
  
or if this path does not exist by ::

  server-root + default-host + document-root
  
A small example should make this thinking clean: ::

  /var/www/
  /var/www/logs/
  /var/www/servers/
  /var/www/servers/www.example.org/
  /var/www/servers/www.example.org/lib/
  /var/www/servers/www.example.org/pages/
  /var/www/servers/mail.example.org/
  /var/www/servers/mail.example.org/lib/
  /var/www/servers/mail.example.org/pages/
  
  simple-vhost.server-root = "/var/www/servers/"
  simple-vhost.default-host = "www.example.org"
  simple-vhost.document-root = "pages"

You can use symbolic links to map several hostnames to the same directory.

Conditionals vs. simple-vhost
-----------------------------

You have to keep in mind that conditionals and simple-vhost interfere. ::

  simple-vhost.server-root = "/var/www/servers/"
  simple-vhost.default-host = "www.example.org"
  simple-vhost.document-root = "pages"

  $HTTP["host"] == "news.example.org" {
    server.document-root = "/var/www/servers/news2.example.org/pages/"
  } 

Even if the ``server.document-root`` will be set to ``/var/www/servers/news2.example.org/pages/`` 
if ``news.example.org`` is requested simple-vhost will overwrite ``server.document-root`` shortly
afterwards.

If ``/var/www/servers/news.example.org/pages/`` exists it will be taken, if not 
``/var/www/servers/www.example.org/pages/`` will be taken as it is the default.

To get them working in parallel you should use: ::

  $HTTP["host"] !~ "^(news\.example\.org)$" {
    simple-vhost.server-root = "/var/www/servers/"
    simple-vhost.default-host = "www.example.org"
    simple-vhost.document-root = "pages"
  }

  $HTTP["host"] == "news.example.org" {
    server.document-root = "/var/www/servers/news2.example.org/pages/"
  } 

It will enable simple-vhosting for all host with are not named ``news.example.org``. 

Options
=======

simple-vhost.server-root
  root of the virtual hosting
  
simple-vhost.default-host
  use this hostname if the 
  
simple-vhost.document-root
  path below the vhost-directory
  
