1

I am trying to configure lighttpd to serve an application (let's call it "foo") that is using a non-standard index page (e.g. "bar.html") as it's start page from a different document-root than the rest of the pages.

Here is what I have:

$HTTP["host"] =~ "^www.example.com$" {
    server.document-root = "/usr/local/www/default"

    url.rewrite-once = (  "^/foo/$" => "/baz/bar.html" )
    alias.url += ( "/foo/" => "/usr/local/www/baz/" )
}

The idea is that internally, lighttpd serves /usr/local/www/baz/bar.html when the URL http://example.com/foo/ is called.

But somehow this does not work. I am not 100% sure what is going wrong but one thing I noticed is that (sometimes?) I get a trailing slash in the URL (something like http://example.com/foo/bar.html/).

It seems to be doing something (and actually something not too far from what I am trying to do) but not exactly what I intend.


UPDATE: from https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModAlias I have learned that no trailing slash should be used on the left hand side in alias.url (but should on the right hand side). So I tried

alias.url += ( "/foo" => "/usr/local/www/baz/" )

to no avail.

scherand
  • 183
  • 9

1 Answers1

0

The url.rewrite is changing the URL to "/baz/bar.html" before the alias.url is matching against the URL. Try this:

$HTTP["host"] =~ "^www.example.com$" {
    server.document-root = "/usr/local/www/default"

    url.rewrite-once = (  "^/foo/$" => "/baz/bar.html" )
    alias.url += ( "/baz/" => "/usr/local/www/baz/" )
}
gstrauss
  • 276
  • 1
  • 5