Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two sub-domains which I want to redirect to the same directory:

$HTTP["host"] =~ "sub1\.example\.com$" {
    server.document-root = "/home/adam/html/sub_domain" 

$HTTP["host"] =~ "sub2\.example\.com$" {
    server.document-root = "/home/adam/html/sub_domain" 

Naturally, I've tried:

$HTTP["host"] =~ "sub1\.example\.com$" OR $HTTP["host"] =~ "sub2\.example\.com$"{
    server.document-root = "/home/adam/html/sub_domain" 

But got:

2011-03-14 10:19:30: (configfile.c.855) source: /etc/lighttpd/lighttpd.conf 
    line: 199 pos: 36 parser failed somehow near here: or

This failed with OR (upper case), or and even c-style ||.

Any idea how to avoid the awkward code repetition?

This question is a copy of an unanswered post I've published in the lighttpd forum.

share|improve this question

Why not just...?

$HTTP["host"] =~ "^sub(1|2)\.example\.com$" {
    server.document-root = "/home/adam/html/sub_domain" 
share|improve this answer
Note: This method does not work with $SERVER["socket"]. – starbeamrainbowlabs Apr 30 '15 at 14:16

Try -o for logical OR. Try -a for logical AND.

Also reference this page for some more operator commands in *nix.

report back and let us know if that works!

share|improve this answer
Does not work: 2011-03-14 14:04:05: (configfile.c.855) source: lighttpd.conf line: 200 pos: 36 parser failed somehow near here: -o – Adam Matan Mar 14 '11 at 14:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.