Hi,
wo sollte die Zeile `index index.php index.html index.htm;`hin? Innerhalb des location-Block, oder außerhalb, oder an beiden Stellen so wie hier. Ich finde im Netz alles mögliche, aber wie ist es eigentlich richtig?
wo sollte die Zeile `index index.php index.html index.htm;`hin? Innerhalb des location-Block, oder außerhalb, oder an beiden Stellen so wie hier. Ich finde im Netz alles mögliche, aber wie ist es eigentlich richtig?
Code:
server {
listen [::]:80;
listen 80;
server_name example.com www.example.com;
root /var/www/example/Web;
access_log /var/log/nginx/example.com.log;
error_log /var/log/nginx/example.com.error.log;
index index.php index.html index.htm;
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 30d;
}
location / {
rewrite ".*" /index.php last;
}
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php$is_args$args;
location ~ ^(.*)\.php$ {
try_files $uri = 404;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_read_timeout 240;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
}
}