这是我想出的有效配置:
Django 媒体设置:
MEDIA_ROOT = '/Users/Me/Development/Web Projects/mysite/mysite/public_html'
MEDIA_URL = 'http:/mysite.local/'
ADMIN_MEDIA_PREFIX = '/'
Apache 虚拟主机配置:
<VirtualHost *:80>
ServerAdmin webmaster@mysite.local
ServerName mysite.local
ErrorLog "/private/var/log/apache2/mysite.local-error_log"
CustomLog "/private/var/log/apache2/mysite.local-access_log" common
WSGIScriptAlias / "/Users/Me/Development/Web Projects/MySite/django.wsgi"
<Directory "/Users/Me/Development/Web Projects/MySite/">
Allow from all
</Directory>
AliasMatch ^/(.*\.[A-Za-z0-9]{1,5})$ "/Users/Me/Development/Web Projects/MySite/public_html/$1"
<Directory "/Users/Me/Development/Web Projects/MySite/public_html">
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
基本上,此设置将使用文件扩展名(我将我的扩展名限制为 5 个字符或更少)作为静态文件提供任何请求,所有其他请求都将发送到我的 Django 应用程序。