67๐
You should use alias
instead of root
. root
appends the trailing URL parts to your local path (e.g. http://test.ndd/trailing/part, it will add /trailing/part to your local path). Instead of that, alias
does exactly what you want: when http://test.ndd/static/ is requested, /static is mapped to your alias exactly, without appending static again.
For example:
location /static {
alias /var/www/django/ecerp/erp/static/;
}
And if file /var/www/django/ecerp/erp/static/foo.html
exists then going to /static/foo.html
will return its contents.
19๐
TL;DR โ you should check your files permissions
Stumbled upon this question and I was already using alias
instead of root, so while the existing answer was up to the point, the following could be useful to others.
In my case, the solution to the same symptoms turned out to be the files in static/
having root
as owner.
A simple chown www-data:www-data .
solved the problem, and no more 404
.
- [Django]-Error 111 connecting to localhost:6379. Connection refused. Django Heroku
- [Django]-Why does django's prefetch_related() only work with all() and not filter()?
- [Django]-Django vs. Model View Controller