[Answer]-My foo.js works in Django runserver but in Apache (wsgi) i get 404. Why?

1👍

Did you set up Apache to serve the directories set as MEDIA_ROOT and STATIC_ROOT at MEDIA_URL and STATIC_URL, respectively? In development, Django serves the static media for you so you don’t need a full webserver stack, but in production, it’s up to you to serve the files.

UPDATE

Just remove the AliasMatch lines. They’re unnecessary if you’ve already set up Alias directives for both /media/ and /static/. All static resources will be in one of those two directories.

Also, don’t forget to run python manage.py collectstatic. Otherwise, the directory specified as STATIC_ROOT will be empty, which would obviously also result in 404s.

Leave a comment