
VirtualHost {
        Hostname = www.domain.com
        WebsiteRoot = /var/www/www.domain.com
        StartFile = index.php
        AccessLogfile = /var/www/www.domain.com/log/access.log
        ErrorLogfile = /var/www/www.domain.com/log/error.log
        TimeForCGI = 5
        UseFastCGI = PHP5
        UseToolkit = nailsdb
        PreventCMDi = yes
        PreventCSRF = yes
        PreventSQLi = yes
        PreventXSS = yes
}
UrlToolkit {
        ToolkitID = nailsdb
        Match http://^domain\.com$ Redirect http://www.domain.com
}
VirtualHost {
        Hostname = www.domain.com, domain.com
        ...
VirtualHost {
        Hostname = www.domain.com
        ...
}
VirtualHost {
        Hostname = domain.com
        ...
        UseToolkit = redirect
}
UrlToolkit {
        ToolkitID = redirect
        Match ^/(.*) Redirect http://www.domain.com/$1
}
$HTTP["host"] =~ "^([^.]+\.[^.]+)$" {
       url.redirect = ( "^/(.*)" => "http://www.%1/$1" )
}
VirtualHost {
  Hostname = example.com, *.example.com
  Redirect = 301:example.com:www.example.com
}
VirtualHost {
  Hostname = www.domain1.com
  ...
}
VirtualHost {
  Hostname = www.domain2.com
  ...
}
VirtualHost {
  Hostname = domain1.com, domain2.com
  ...
}
<?php
header("Location: http://www.".$_SERVER["HTTP_HOST"]."/");
?>
[~]% telnet www.slashdot.org 80
Trying 216.34.181.48...
Connected to www.slashdot.org.
Escape character is '^]'.
GET / HTTP/1.1
Host: www.slashdot.org
HTTP/1.1 301 Moved Permanently
Server: Apache/1.3.41 (Unix) mod_perl/1.31-rc4
Location: http://slashdot.org/
Content-Type: text/html; charset=iso-8859-1
Content-Length: 297
Date: Thu, 28 Jan 2010 23:53:48 GMT
X-Varnish: 1107128597 1107127750
Age: 46
Connection: keep-alive
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>301 Moved Permanently</TITLE>
</HEAD><BODY>
<H1>Moved Permanently</H1>
The document has moved <A HREF="http://slashdot.org/">here</A>.<P>
<HR>
<ADDRESS>Apache/1.3.41 Server at www.slashdot.org Port 80</ADDRESS>
</BODY></HTML>