Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lighttpd: Let sub-path point to different document root

I have a lighttpd-Setup pointing to the document-root /var/www. However, I want the URL other/ to point to /some/other/dir. This I'm doing with the following config:

$HTTP["url"] =~ "^/other($|/)" {
  server.document-root = "/some/other/dir"
}

However, if I access 'http://myhost/other', lighttpd tries to access /some/other/dir/other instead of just /some/other/dir. Is it possible to somehow strip the /other but keep any further URL segments? So for instance, http://myhost/other/sub/foo.txt should point to /some/other/dir/sub/foo.txt.

like image 826
Remo Avatar asked Nov 13 '12 12:11

Remo


1 Answers

Instead of trying to set server.document-root, you can use mod_alias to achieve this:

server.modules = ( ..., "mod_alias" )

...

alias.url = ( "/other/" => "/some/other/dir/" )

This will create an alias such that all requests to /other/ and resources inside that folder will be redirected to /some/other/dir/ on the file system, with a request directly to /other/ being pointed directly to the root of /some/other/dir/, just like you want.

like image 166
Greg Avatar answered Nov 07 '22 08:11

Greg