Hey everybody, First sorry for my bad english . Just starting with nginx, everything works great except 404 page ! Instead of my wordpress 404 page, nginx show default 404 page. My "normal" 404 page are located in my theme folder, named: 404.php My current nginx directives: Code: server { server_name www.mywebsite.com; return 301 $scheme://mywebsite.com$request_uri; listen 80; port_in_redirect off; root /var/www/clients/client0/web2/web/; index index.php; # Rocket-Nginx configuration include rocket-nginx/default.conf; location / { try_files $uri $uri/ /index.php?$args; } # Deny public access to wp-config.php location ~* wp-config.php { deny all; } location ~ \.php$ { try_files $uri =404; include fastcgi_params; fastcgi_pass unix:/run/php/php7.0-fpm.sock; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } } Personalized 404 page box unchecked. What's wrong ? Thanks a lot
Replace your nginx directves with: Code: location / { try_files $uri $uri/ /index.php?$args; } # Add trailing slash to */wp-admin requests. rewrite /wp-admin$ $scheme://$host$uri/ permanent; location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ { expires max; log_not_found off; }
This needs to be added to every site that uses WordPress. A different CMS might need no code at all or a different code. Btw, it's the same for apache web servers, just that WordPress delivers the code for apache on its own inside a .htaccess file. You can use directive snippets to manage such snippets easily in ISPConfig.