Hi people,
I'm having a problem on my Nginx installation and WordPress. Even if the WordPress 404 return correctly on every page, on non existent files.php returns the standard Nginx 404 page, not the WordPress one. This is my Nginx configuration file. How can I solve this?
Thanks!
fastcgi_cache_path /etc/nginx/cache/domain.tld/ levels=1:2 keys_zone=domain.tld:100m inactive=60m;
server {
listen *:80;
server_name domain.tld www.domain.tld;
root /var/www/domain.tld/web/;
index index.html index.htm index.php index.cgi index.pl index.xhtml;
error_log /var/log/ispconfig/httpd/domain.tld/error.log;
access_log /var/log/ispconfig/httpd/domain.tld/access.log combined;
location ~ /\.(?!well-known/acme-challenge/) {
deny all;
access_log off;
log_not_found off;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ \.php$ {
try_files /b13d29a00e30846cadcfe27cac5e99c7.htm @php;
}
location @php {
try_files $uri =404;
add_header X-Cache $upstream_cache_status;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/lib/php7.0-fpm/web1.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
fastcgi_cache domain.tld;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache_valid 200 60m;
fastcgi_intercept_errors on;
}
set $skip_cache 0;
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $skip_cache 1;
}
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
location ~ /purge(/.*) {
fastcgi_cache_purge domain.tld "$scheme$request_method$host$1";
}
location / {
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~* ^.+\.(css|js|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}