Django,apache-wsgi - 服务器正在服务 /js 和 /css 但无法提供图像

Django, apache-wsgi - server is serving /js and /css but cannot serve images

静态目录结构:

website
--css
--js
--images
  --landinpage.png

Apache 访问日志:

"GET /static/website/js/jquery.js HTTP/1.1" 200"
"GET /static/website/images/landinpage.png HTTP/1.1" 404

HTML代码:

<code>

    <!-- Styles -->
    <link rel="stylesheet" type="text/css" href="/static/website/css/style.css"/>

<style>
body {
    background: white url("/static/website/images/landinpage.png");
</code>

我可以看到 /static/website/css/style.css 正在正确加载(因此在 apache 日志中有 200 个服务器响应),但是当服务器尝试加载 /static/website/images/landinpage.png 我收到 404 响应. 我已验证文件名和位置

如果静态服务器apache2:

settings.py中添加静态目录

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

将静态收集到目录

manage.py collectstatic

在 apache conf 添加路径

Alias /static/ /var/www/static/

如果开发服务器。

模板上下文处理器settings.py

'django.template.context_processors.static',

urls.py

from django.conf import settings
from django.conf.urls.static import static

if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)