lighttpd domains and url matching

Posted by Manuel on Server Fault See other posts from Server Fault or by Manuel
Published on 2012-05-30T13:17:11Z Indexed on 2012/06/01 10:43 UTC
Read the original article Hit count: 202

Filed under:

I'm trying to configure lighttpd so that:

  • www.domain1.org/admin uses config1
  • any other URL on www.domain1.org uses config2
  • any url on www.domain2.org uses config2

So basically, domain1 and domain2 should use the same configuration except for when domain1 is accessed via an URL that starts with /admin

I tried so far a number of variations, including this one:

$HTTP["host"] =~ "domain1.org" {
  $HTTP["url"] =~ "^/admin" {
    // config1

    alias.url = ("/media/admin" => "/usr/share...",
                 "/static" => "/var/www/...")

    url.rewrite-once = (
      "^(/media/admin.*)$" => "$1",
      "^(/static.*)$" => "$1",
      "^/favicon\.ico$" => "/media/favicon.ico",
      "^(/.*)$" => "/application.fcgi$1",
    )
    server.document-root="/var/www/application"
    fastcgi.debug = 1

    fastcgi.server = (
      "/application.fcgi" => (
          "main" => (
              "socket" => "/var/www/application/application.sock",
              "check-local" => "disable",
          )
      ),
    )

  } else $HTTP["url"] !~ "^/admin" {
    // config2
  }

$HTTP["host"] !~ "domain1.org" {
   // config2
}

But no matter what, accessing domain1.org/admin yields a 404.

Is there anything that I am missing?

© Server Fault or respective owner

Related posts about lighttpd