views:

118

answers:

1

I know that there is already a question (actually some more) about this, but the answers to them didn't help me out very much, as I am pretty new to lighttpd.

I have one folder which contains .pdf-files. When doing a HttpResponseRedirect to the locations of one of those .pdf-files, the user should be able to download the .pdf file (or view it in the browser). Right now, Django just redirects to my "home" html page, without showing any pdf-file.

Somehow, I will have to tell lighttpd that Django shouldn't handle this directory anymore. Is this the only thing I need to do? If yes, how should i do it?

+2  A: 

Did you saw the section "lighttpd setup" in the Django docs? Using alias.url an url.rewrite-once you can route the requests to you app or a folder serving files:

alias.url = (
    "/pdfs" => "/path/to/my/pdfs",
)

url.rewrite-once = (
    "^(/pdfs.*)$" => "$1",
    "^(/.*)$" => "/mysite.fcgi$1",
)
aeby
does this also work for subfolders of "/pdfs"?btw., thanks for your answer. When i go to "/path/to/my/pdfs" (other path for me, of course), django returns "Directory indexes are not allowed here.", so it seems it is still handling it.
ptikobj
What URL do you use? 127.0.0.1:8000/pdfs/file1.pdf or something like this. Are you sure, that the "Directory indexes are not allowed here." message is not from lighttpd? Perhaps you need to enable directory listing with mod_dirlisting (http://redmine.lighttpd.net/wiki/1/Docs:ModDirlisting)
aeby
the fault was a totally different one, i missed a slash in the argument of HttpResponseRedirect...
ptikobj