2016-12-26 11 views
0

Hier ist meine statische Website Verzeichnisbaum:Serving HTML/CSS/JS-Dateien mit nginx

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

Hier ist meine 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; 
    } 
} 

jedoch nicht css/js-Dateien laden können, heißt es 404 nicht gefunden. Was ist los mit dir?

Antwort

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

löste meine Probleme.