lighttpd virtual hosting configuration

Solution 1:

You'll want some configuration along these lines:

$HTTP["host"] == "web1.com" {
    server.document-root = "/var/www/web1.com/public_html"
}
$HTTP["host"] == "web2.com" {
    server.document-root = "/var/www/web2.com/public_html"
}

That should be all that's needed to get those two directories mapped to those two host headers. If that doesn't work, can you go into more detail about what kind of problems you're seeing when attempting to use this config?

Edit:

To have the www domains redirect to non-www, use a configuration like this:

$HTTP["host"] =~ "^www\.(.*)$" {
  url.redirect-code = 301
  url.redirect = (
    "/(.*)" => "http://%1/$1" 
  )
}