繁体   English   中英

如何使用mod_wsgi和Django提供静态文件?

[英]How to serve static files with mod_wsgi and Django?

我想使用mod_wsgi提供静态plist文件。 在配置了apache如下

Alias /site_media/ "/var/www/mysite/media/"
<Directory "/var/www/mysite/media">
Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing
</Directory>

当我转到http://localhost/mysite/site_media/mac_config.plist ,出现错误

Page not found (404)
Request Method: GET
Request URL:    http://localhost/mysite/site_media/mac_config.plist
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^config/
^admin/doc/
^admin/
The current URL, site_media/mac_config.plist, didn't match any of these.

这个错误告诉我Django正在拦截请求。 如何在不使用python从磁盘读取文件并使用http请求响应的情况下提供此静态文件?

就像@sdolan建议的那样,执行localhost/site_media/mac_config.plist纠正此问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM