$HTTP["host"] =~ "awstats\.(.*)$" {
  var.domain = "%1"
  
  server.document-root = "/var/www/htdocs/domains/rc6.org/subdomains/awstats.rc6.org"

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

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

  url.rewrite-once = (
    "^/stats" => "/cgi-bin/awstats.pl?config=" + domain,
    "^/awstats\.pl(.*)" => "/cgi-bin/awstats.pl$1"
  )

}
