Report this

What is the reason for this report?

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

Posted on December 9, 2020

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;
    }


This textbox defaults to using Markdown to format your 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 :

https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-to-use-custom-error-pages-on-ubuntu-14-04

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;
                internal;
        }

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

Regards, KFSys

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.