1

What is the best or proper way to specify two http hosts with the same document root on Lighttpd? For example, to serve a domain at example.org and www.example.org.

Given the following in the lighttpd.conf for one host:

$HTTP["host"] == "www.example.org" {
  server.document-root = "/path/to/root/example" 
}

Is this a valid configuration for two hosts?

$HTTP["host"] == ( "example2.org", "www.example2.org" ) {
  server.document-root = "/path/to/root/example2" 
}

Or do you have have to duplicate/repeat the $HTTP["host"] field for each?

user981178
  • 445
  • 1
  • 3
  • 13
  • I had a complete brain fart and wrote up a whole answer for nginx :-D I'm not sure how to set this up in lighttpd but the correct thing to do is to pick one name to be the "canonical" hostname and redirect the "wrong" hostname to the right one with a 301 redirect. Google's explanation is [here](https://support.google.com/webmasters/answer/44231?hl=en). – DerfK Apr 28 '16 at 23:15
  • Thanks for the information. This is something to consider, but there might still be times when the two hosts are wanted, so hopefully someone can answer. – user981178 Apr 29 '16 at 00:22

1 Answers1

0

No, this does not appear to work when testing the configuration file with:

# lighttpd -t -f lighttpd.conf

I guess each $HTTP["host"] field has to be separate, with the server.document-root repeated if you want different sub-domains to serve the same site data.

user981178
  • 445
  • 1
  • 3
  • 13