server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com;
index index.php index.html;
access_log off;
error_log /var/log/nginx/example.com-error.log;
charset utf-8;
# Redirect from www
if ($host = 'www.example.com' ) {
rewrite ^/(.*)$ http://example.com/$1 permanent;
}
# Protect folders
location ~ /(vendor|src)/ {
deny all;
}
# All requests to index.php
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# PHP-FPM on Unix-socket
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
|