Home > Blockchain >  nginx 404 not found on url click
nginx 404 not found on url click

Time:06-29

I am using nginx and wordpress. here is my nginx config :

server {
        listen *:443 ssl;

        root /var/www/wordpress;
        ## This should be in your http block and if it is, it's not needed here.
        index index.php;
 
        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }
 
        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
 
        location / {
                # This is cool because no php is touched for static content.
                # include the "?$args" part so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php?$args;
        }
 
        location ~ \.php$ {
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi.conf;
                fastcgi_intercept_errors on;
                fastcgi_pass php;
        }
 
        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
             location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                         expires max;
                         log_not_found off;
           }
}
    

the website works fine but when I click a link that redirects to another page, nginx gives a 404 not found page.

what should I add in the config file so nginx allows all urls?

CodePudding user response:

the answer was to change== the nginx configuration from :

location / {
  try_files $uri $uri/ /404;
}

to 

location / {
try_files $uri $uri/ /index.php?$args;
}

here is a link that can help https://bobcares.com/blog/nginx-wordpress-permalinks-404-error/

  • Related