PDA

View Full Version : multiple hosts with lighttpd


evan
06-25-2006, 09:33 PM
Hi,

In the Rimuhosting Wiki you say that you don't know if lighttpd can support multiple hostnames in one process. It can; it's easy. You just set up multiple virtual hosts and use a regular expression to check the $HTTP["host"] environment variable, which the browser passes along with the request (assuming it's been made after ~1995).


$HTTP["host"] =~ "^blog.evanweaver.com" {
# your configuration here
}

$HTTP["host"] =~ "^www.rimuhosting.com" {
# your other configuration here
}


and you can rewrite incoming requests that lack the subdomain like this:


$HTTP["host"] =~ "^(www\.|)evanweaver\.com$" {
url.redirect = (
"^/(.*)" => "http://blog.evanweaver.com/$1",
"" => "http://blog.evanweaver.com/"
)
}


I tried to leave a comment on the wiki, but i couldn't find a way to register even though it has a comment link.

Evan Weaver (http://blog.evanweaver.com)