• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Issue error_page in additional nginx directives

groovyjon

Basic Pleskian
I can't seem to get the error_page directive working in nginx.

I have the following directive in the Apache settings which works fine when I go to a non-existent page/folder on the website:

ErrorDocument 404 /notfound.php

But if I try to go to a non-existent page with a .php extension then it just shows a "File not found" message.

I have put the following in the "additional nginx directives" but it has no effect:

error_page 404 /notfound.php;
location = /notfound.php {
root /var/www/vhosts/mydomain.com/httpdocs;
internal;
}

What am I doing wrong?

Running Plesk Onyx 17.5.3 Update #11 on Ubuntu 16.04.2 LTS
 
Similar to Question - Custom 404 error page if you useing nginx
where it is referred to Setting Up Custom Error Pages on Linux Servers

Is your PHP version set to "PHP-FPM served by Nginx"? I think the easiest workaround for the issue could be to change that setting to "PHP-FPM served by Apache", because it will then not even care what the Nginx configuration is, but Nginx will forward all .php requests to Apache. And as you say that your Apache config works, it could be a possible way to resolve it.
 
If it is set to Apache, Nginx forwards all dynamic requests to Apache.

Maybe the "not found" error does not result from the first file that is not found, but from the "notfound.php" file not found? That could be solved by providing a fully qualified URL instead of only the filename /notfound.php, for example
ErrorDocument 404 http://mydomain.tld/notfound.php
It is possible, too, that in your .htaccess file there is an additional ErrorDocument directive for the 404. That would override the directive you set in the Apache configuration section.

If that does not work, you could consider removing the directive in general and placing your 404 not found file into the error documents directory as described in Setting Up Custom Error Pages on Linux Servers Have you tried that?
 
The fully qualified URL didn't make any difference.

I haven't put any of my own .htaccess files on the server if that's what you mean in your second point.

I will look at the error documents directory method now.
 
However, the problem with using the error_docs directory is that it looks like I'm restricted to html files. I would like to have a PHP page displayed so it can include some other files too.
 
Hi groovyjon,

you could try to solve your issue with this additional apache modification:
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} \.php$
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
    RewriteRule (.*) - [H=text/html]
</IfModule>
 
Back
Top