Search code examples
wordpressnginxpermalinks

wordpress - 404 page not found after updating permalinks w Nginx


I changed my permalinks structure to use the postname I restarted Nginx to clear the cache, but even if I can display my homepage, when I hit any oage link , I get a 404 page not found ...

Using Nginx , I don't have to update the .htaccess file , but should I update my site Nginx conf file ...

here is the location section used with .php

      location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass 127.0.0.1:9000;
            # fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params; }

thanks for feedback


Solution

  • It's not a complete file section! server { } is missing.

    Use this one but use this one between server { } and should work

    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass 127.0.0.1:9000;
            # fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params; 
    }
    if (!-e $request_filename) {
        rewrite ^.*$ /index.php last;
     }