Lighttpd
上QQ阅读APP看书,第一时间看更新

Extended Virtual Hosting

Too simple? Well, we can gain one level of complexity by using mod_evhost. The "e" stands for extended and while it does a little more than mod_simple_vhost, the configuration is even more minimal. In fact, there is only one option:

evhost.path-pattern = "/var/www/vhost/%3.%0/htdocs"

This example would do exactly the same as the code above, only using mod_evhost instead of mod_simple_vhost. The percent-signs with numbers are placeholders for the following values (in our example for the subdomain some.domain.myvirtualhost.net):

This implies that "%0" could also be stated as "%2.%1". We do not gain much flexibility over mod_simple_vhost; the most common usage is:

evhost.path-pattern = "/var/www/vhost/%0/%3/htdocs"

So, we can have a directory per-domain containing a directory for each subdomain, or if we serve only one domain, we can leave out the domain name:

evhost.path-pattern = "/var/www/vhost/%3/htdocs"

Now, we have omitted the domain name in our path. We can also use a similar pattern to create per-user homepages under http://username.myvirtualhost.net where every user has a home directory under /home/username with a subdirectory html:

evhost.path-pattern = "/home/%3/html"