简体   繁体   中英

AliasMatch in httpd.conf with django admin

I have a problem with Alias in apache with django. In my wsgi.conf I have the following alias:

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

The alias works fine but in my django admin I get the static only in some pages. The problem is related with the alias path because the django admin includes additional parts to the url according to the section. An example following:

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

For each django app, additional information is added to the url and the Alias fails to resolve. Are there any way to map this situation using AliasMatch instead Alias?

I suppose that I can map manually every additional path using a simple alias but that is not an efficient and comfortable solution...

Thanks!!

You should not have to go through all that mapping. Is your STATIC_URL set to a root directory like /static/ ? If so, you should only need Alias /static/ /opt/python/current/app/django_eb/static/ and don't forget to run collectstatic . – Nostalg.io

you are right my problem was related with the STATIC_URL I had set it to static/. I have changed it to /static/ and now it works smooth – rdiaz82

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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