Project

General

Profile

doc-root

Added by peto about 10 years ago

This is a straightforward case: I want ~/static/* to be available as http://example.com/static/*. I can't seem to find a way to do this cleanly.

The dumb way would be to move ~/static to ~/dummy/static, and use:

$HTTP["url"] =~ "^/static/" {
    server.document-root = "/home/user/dummy" 
}

That's no good; I don't want to move my entire static file directory down a level. This is too simple a configuration for me to need to navigate down an extra placeholder directory level every time I access it. (I could stick a symlink somewhere--and that's probably what I'll end up doing if I don't find a real solution--but this seems so basic that it's got to be possible.)

This works, but is bad:

$HTTP["url"] =~ "^/static/" {
    server.document-root = "/home/user" 
}

Of course, that's a huge security hole, since it'll allow symlinks out of ~/static.

This was the first thing I tried, but it doesn't work:

$HTTP["url"] =~ "^/static/" {
    server.document-root = "/home/user/static" 
    url.rewrite-once = ( "^/static(/.*)" => "$1" )
}

I think rewriting happens before conditions are matched or something, but I'm not sure.

This seems like an incredibly simple case; I must be missing something obvious.


Replies (3)

RE: doc-root - Added by peto about 10 years ago

Something obvious, indeed: mod_alias. I don't think I'll be using lighttpd for this deployment, though; probably back to Apache. It's just too dead here.

RE: doc-root - Added by nitrox about 10 years ago

I´m not quite sure what you want to do, but mod_userdir has some path-settings you mind find useful.
Or is it all about getting rid of "~"?

mod_userdir

RE: doc-root - Added by icy about 10 years ago

No he doesn't want userdir, there's no ~ in the url. And yep, mod_alias is the solution to this problem.
Unfortunately mod_rewrite doesn't work inside url conditionals as you correctly mentioned, rewriting happens before conditional evaluation.
It will be better in 2.0 - promised! :) You can do rewriting wherever you want there.

What do you mean by "too dead here"? If you mean the forum: yea it could benefit from more people helping out, I try to answer questions every now and then whenever I have some free time.

Oh and the IRC channel is pretty active. You usually get an answer to a question within minutes, there are many people in there.
You'd be welcomed to join us there.

    (1-3/3)