httpd.conf 中的 AliasMatch 与 django 管理员

AliasMatch in httpd.conf with django admin

我在使用 Django 的 Apache 中遇到 Alias 问题。在我的 wsgi.conf 中,我有以下别名:

Alias /admin/static/ /opt/python/current/app/django_eb/static/
<Directory /opt/python/current/app/django_eb/static>
  Require all granted
</Directory>

别名工作正常,但在我的 Django 管理员中,我只在某些页面中获得静态。该问题与别名路径有关,因为根据该部分,django 管理员在 url 中包含其他部分。示例如下:

http://blablabla.com/admin/**auth/group**/static/admin/css/base.css/

对于每个 Django 应用程序,额外的信息被添加到 url 并且别名无法解析。有什么方法可以使用 AliasMatch 而不是 Alias 来映射这种情况?

我想我可以使用一个简单的别名手动映射每个附加路径,但这不是一个有效且舒适的解决方案...

谢谢!!

您不必完成所有这些映射。您的 STATIC_URL 是否设置为 /static/ 之类的根目录?如果是这样,你应该只需要Alias /static/ /opt/python/current/app/django_eb/static/并且不要忘记运行 collectstatic。 – Nostalg.io

你是对的,我的问题与 STATIC_URL 我将其设置为静态/有关。我已将其更改为 /static/,现在它运行流畅 – rdiaz82