简体   繁体   English

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

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

I would like to serve static plist files using mod_wsgi . 我想使用mod_wsgi提供静态plist文件。 In have configured apache as follows 在配置了apache如下

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

When I go to http://localhost/mysite/site_media/mac_config.plist I get the error 当我转到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.

This error is telling me that Django is intercepting the request. 这个错误告诉我Django正在拦截请求。 How is it possible to serve this static file without having to use python to read the file from disk and respond with an http request? 如何在不使用python从磁盘读取文件并使用http请求响应的情况下提供此静态文件?

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

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

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