Wordpress and nginx all pages works fine except for non-existent .php

I configured my WordPress website on Nginx and everything works fine but for non-existent .php pages Those return the nginx default 404 page not found why ?

location / { #try_files $uri $uri/ =404;

    try_files $uri $uri/ /index.php$is_args$args;


location ~ .php$ { include snippets/fastcgi-php.conf;

            # With php7.4-fpm:
            fastcgi_pass unix:/run/php/php7.4-fpm.sock;

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @mhcoding1,

You can configure a custom 404 page if you wish. You can follow this DigitalOcean tutorial :

Don’t mind it’s old, you can still reuse the code from the server blocks such as

        error_page 500 502 503 504 /custom_50x.html;
        location = /custom_50x.html {
                root /usr/share/nginx/html;

        location /testing {
                fastcgi_pass unix:/does/not/exist;

Regards, KFSys