Some time ago, I needed to have several subdomains working, without having to define them in lighttpd. The domains had to be mapped like this:
bredsaal.domain.com -> /var/www/domain.com/bredsaal/
testhomepage.domain.com -> /var/www/domain.com/testhomepage/
and so on.
Setting this up in lighttpd is actually VERY easy.
First, you should enable mod_evhost in /etc/lighttpd/lighttpd.conf by removing the # in front of it, in the server.modules section of the configuration file.
Next, you should add a section that handles the virtual host. For the domain specified above, I used this:
$HTTP["host"] =~ "\.domain\.com$" {
evhost.path-pattern="/var/www/domain.com/%3/"
server.errorlog = "/var/log/lighttpd/domain_error.log"
accesslog.filename = "/var/log/lighttpd/domain_access.log",
}
The line that does the magic is of course evhost.path-pattern="/var/www/domain.com/%3/", where %3 is the subdomain.
Read more about mod_evhost here.
Related posts:




