Nginx directives + Wordpress, Default 404 issue

Discussion in 'General' started by StoneDB, Jul 21, 2017.

  1. StoneDB

    StoneDB New Member

    Hey everybody,

    First sorry for my bad english :).

    Just starting with nginx, everything works great except 404 page :mad: !

    Instead of my wordpress 404 page, nginx show default 404 page.

    [​IMG]

    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
     
    Last edited: Jul 21, 2017
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    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;
    }
    
     
    StoneDB likes this.
  3. StoneDB

    StoneDB New Member

    Hey thanks till, but your directives doesn't works too, have the same 404 page :/
     
  4. ahrasis

    ahrasis Active Member

    Other than the added nginx directives, is your WP website using default vhost created by ISPC?

    My vhost for all sites is a bit cistomized but for WP sites' directives, I am only using / adding this:
    Code:
            location / {
                try_files $uri $uri/ /index.php?q=$uri&$args;
            }
    
     

Share This Page