Fetching static files failed with 404 in nginx

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)