0

What is the difference between the following? Both work the same way from what I can tell/use it for

$HTTP["host"] =~ "a.domain.com" {
    server.document-root = "/var/www/a/"
}

$HTTP["host"] == "a.domain.com" {
    server.document-root = "/var/www/a/"
}

Would the =~ match x.a.domain.com?

j0k
  • 22,600
  • 28
  • 79
  • 90
cantsay
  • 1,967
  • 3
  • 21
  • 34
  • 1
    From http://thomashunter.name/blog/subdomains-and-google-apps-with-gandi-and-linode/ *"The lighttpd configuration file uses a proprietary syntax (although it kinda looks like a cross between PHP and JSON). The Tilde Equal lines are a regular expression which match the requested domain name and apply the rules within that section."* – Robert Harvey Feb 13 '13 at 22:19

1 Answers1

2

The right-hand side of =~ is a regular expression.

x.a.domain.com would not match the regular expression a.domain.com.

Examples that would match:

  • axdomain.com
  • axdomainxcom
  • aydomainycom
  • a1domain1com
  • ...

Is the example from a real-world example? It seems kinda pointless.

Something like this could be more meaningful:

$HTTP["host"] =~ ".*\.somedomain\.com" {
    server.document-root = "/var/www/somedomain.com/"
}

Meaning, serve all requests to *.somedomain.com from /var/www/somedomain.com/

This page has some more realistic examples with regex matching:

http://redmine.lighttpd.net/boards/2/topics/2518

janos
  • 120,954
  • 29
  • 226
  • 236