What is the best way of handling non-existent PHP pages in Nginx? I have the following location block...
location ~ \.php$ {
fastcgi_pass localhost:9000;
include fastcgi_params;
}
I'd like to be able to display a 404 error if a PHP page doesn't exist, I'm guessing I need to get the try_files
(http://wiki.nginx.org/HttpCoreModule#try_files) directive involved by handling all errors with the error_page
directive (declared elsewhere), but am unsure of the best way of doing this.
Any help would be appreciated.
just use error_page(you can change page_not_found.html to php script):
try file need to redirect to a different server, if page not found.