使用 Django / lighttpd 处理静态文件

发布于 2024-08-30 02:37:39 字数 280 浏览 1 评论 0原文

我知道已经有一个关于此的问题(实际上还有更多),但是他们的答案对我没有多大帮助,因为我对 lighttpd 还很陌生。

我有一个包含 .pdf 文件的文件夹。当对这些 .pdf 文件之一的位置执行 HttpResponseRedirect 时,用户应该能够下载 .pdf 文件(或在浏览器中查看它)。现在,Django 只是重定向到我的“主页”html 页面,而不显示任何 pdf 文件。

不知何故,我必须告诉lighttpd Django 不应该再处理这个目录。 这是我唯一需要做的事情吗?如果是的话我该怎么办?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一城柳絮吹成雪 2024-09-06 02:37:39

您是否看到“lighttpd 设置”部分在 Django 文档中?使用 alias.urlurl.rewrite-once 您可以将请求路由到您的应用程序或提供文件的文件夹:

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

url.rewrite-once = (
    "^(/pdfs.*)$" => "$1",
    "^(/.*)$" => "/mysite.fcgi$1",
)

Did you see 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",
)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文