Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to configure lighttpd so that:

  • uses config1
  • any other URL on uses config2
  • any url on 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"] =~ "" {
  $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",
    fastcgi.debug = 1

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

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

$HTTP["host"] !~ "" {
   // config2

But no matter what, accessing yields a 404.

Is there anything that I am missing?

share|improve this question
If it's returning 404 I would think that it's actually the contents of config1 which is the problem. – mgorven May 31 '12 at 0:19
Indeed, I figured out that accessing /admin fails, whereas accessing the fastcgi URL that is part of config1 works (/app.fcgi/admin). I will update the question with more details – Manuel Bernhardt Jun 1 '12 at 9:40

1 Answer 1

up vote 3 down vote accepted


NOTE: url rewriting does not work within a $HTTP["url"] conditional.

Also the rewrites must always use the absolute path, so you should prefix your matches with /admin, and targets and the fastcgi.server match too.

share|improve this answer

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.