3

Here's my static website directory tree:

- website
-- html
--- index.html
-- css
--- styles.css
-- js

Here's my nginx config:

server {
    listen 80;

    root /srv/www/domain.com/website/html;
    index index.php index.html index.htm;

    server_name domain.com;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

However it cannot load css / js files, it says 404 not found. What's wrong?

1 Answer 1

3
   location ~* \.(js|jpg|png|css)$ {
        root /srv/www/domain.com/website/;
        expires 30d;
    }

solved my issues.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.