$HTTP["host"] =~ "^(www\.)?rc6\.org" {
  var.servername = "rc6.org"
  include "incl-docroot.conf"

  # No point in enabling this, since Drupal already
  # does this for us.
  #server.error-handler-404 = "/index.php"

  # Replacement for .htaccess
  url.rewrite-final = (
    # Clean URL test for 4.6
    "^/system/test/(.*)$" => "/index.php?q=system/test/$1",

    # Clean URL test for 4.7
    "^/system/test-clean-url/(.*)$" => "/index.php?q=system/test-clean-url/$1",

    # feed alias
    "/rss.xml$" => "/index.php?q=rss.xml",

    # Search
    "^/search/(.*)$" => "/index.php?q=search/$1",

    # More than one argument
    "^/([^.?]*)\?(.*)$" => "/index.php?q=$1&$2",

    # No arguments
    "^/([^.?]*)$" => "/index.php?q=$1",
  )
}

$HTTP["host"] =~ "at\.rc6\.org" {
  var.subdomain = "at"
  var.servername = "rc6.org"
  include "incl-docsubroot.conf"

  # Rewrite rules for Insipid
  url.rewrite-final = (
    "^/bookmarks/(.*)" => "/insipid.cgi?tag=$1",
    "^/bookmarks" => "/insipid.cgi",
    "^/feeds/bookmarks/(.*)" => "/insipid.cgi?op=rss&tag=$1",
    "^/feeds/bookmarks" => "/insipid.cgi?op=rss",
    "^/snapshot/(.*)" => "/insipid.cgi?op=viewsnapshot&md5=$1",
    "^/.*\?page=(.*)" => "/insipid.cgi?page=$1",
    "^/?$" => "/insipid.cgi",
  )
}

$HTTP["host"] =~ "fm\.rc6\.org" {
  var.subdomain = "fm"
  var.servername = "rc6.org"
  include "incl-docsubroot.conf"

  # Make sure our DI logins stay private
  auth.backend = "htpasswd"
  auth.backend.htpasswd.userfile = "/var/www/htdocs/data/.htpasswd"

  auth.require = ( "/difm/" =>
                   (
                     "method"  => "basic",
                     "realm"   => "Digitally Imported",
                     "require" => "valid-user"
                   )
                 )

}

$HTTP["host"] =~ "imdb\.rc6\.org" {
  var.subdomain = "imdb"
  var.servername = "rc6.org"
  include "incl-docsubroot.conf"
}

$HTTP["host"] =~ "(intranet|bw)\.rc6\.org" {
  var.subdomain = "intranet"
  var.servername = "rc6.org"
  include "incl-docsubroot.conf"
}

$HTTP["host"] =~ "r\.rc6\.org" {
  var.subdomain = "r"
  var.servername = "rc6.org"
  include "incl-docsubroot.conf"

  # Replacement for .htaccess
  url.rewrite-final = (
    "^/(.*)/$" => "/index.php?i=$1"
  )
}

$HTTP["host"] =~ "irc\.rc6\.org" {
  var.subdomain = "irc"
  var.servername = "rc6.org"
  include "incl-docsubroot.conf"

  auth.debug                 = 0
  auth.backend               = "htpasswd"
  auth.backend.htpasswd.userfile = "/var/www/htdocs/data/.htpasswd"
  auth.require = ( "/" => 
    ( 
      "method"  => "basic",
      "realm"   => "url archive",
      "require" => "valid-user"
    )
  )
}

$HTTP["host"] =~ "stats\.rc6\.org" {
  var.subdomain = "stats"
  var.servername = "rc6.org"
  include "incl-docsubroot.conf"
}

$HTTP["host"] =~ "p\.rc6\.org" {
  var.subdomain = "p"
  var.servername = "rc6.org"
  include "incl-docsubroot.conf"
}



