How to enable custom error pages in Plesk - Unix
Posted by zz-James Moir on 21 June 2016 04:07 PM
Custom error pages allow you to show a customised page for all web server errors, but most commonly, 404 Not Found and 500 Internal Errors. This allows you to show a more user friendly or branded page when a page is not found or in the event of 500 Internal Errors, capture or notify the webmaster so that the errors can be corrected.
This article will show you how to enable custom error pages in Plesk under Unix. There is a different method for Windows hosted accounts. See How To Enable Custom Error Pages In Plesk - Windows
There are two methods for using custom error pages for Unix hosted accounts.
If you only wish to modify the default HTML error pages follow the first method using Plesk. If you wish to redirect common error pages to a PHP page you will need to use the second method which uses a .htaccess file.
You can use both FTP and File Manager to upload your custom error document to the server. By default, all error documents are stored in the /error_docs/ directory.
Create a .htaccess file with a text editor and for each error you want to redirect, add the following directive to the .htaccess file:
ErrorDocument 000 /path/to/file
where 000 is the error number e.g. 400, 404, 500) and /path/to/file is the location of your new error document. For example, if you have created an error page at http://www.example.com/errors/404.php then set the path as /errors/404.php
ErrorDocument 404 /errors/404.php
Do this for each custom error document, example:
ErrorDocument 400 /errors/bad-request.php
Save and upload the .htaccess file to the document root of your site or to any folders where you need to change the default document that is loaded when the folder is accessed.