Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
1  
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

See http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModRewrite:

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

 
discard

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.