Search code examples
virtualhostlighttpd

lighttpd virtualhost does not work


I have a server installed lighttpd and I want virtualhosts for my domains. Here it is what I did and it does not work.

lighttpd version is 1.4.35

simple-vhost.server-root = "/var/www/"
simple-vhost.default-host = "mydomain.net"
simple-vhost.document-root = "mydomainnet"

$HTTP["host"] =~ "(^|\.)mydomain.net" {
    server.document-root = "/var/www/mydomainnet"
    server.errorlog = "/var/log/lighttpd/mydomain/error.log"
    accesslog.filename = "/var/log/lighttpd/mydomain/access.log"
    #server.error-handler-404 = "/e404.php"
}

Also domain to ip is correct for my server.


Solution

  • I forgot the '$' at the end of the domains.

    simple-vhost.server-root = "/var/www/"
    simple-vhost.default-host = "mydomain.net"
    simple-vhost.document-root = "mydomainnet"
    
    $HTTP["host"] =~ "(^|\.)mydomain.net$" {
        server.document-root = "/var/www/mydomainnet"
        server.errorlog = "/var/log/lighttpd/mydomain/error.log"
        accesslog.filename = "/var/log/lighttpd/mydomain/access.log"
        #server.error-handler-404 = "/e404.php"
    }