
There are two different ways to display error messages using Plesk on Linux. The first is through Plesk itself, using the Custom Error Documents option and five files in the error_docs/ directory under each domain's home. The second is by using a .htaccess file to change Apache's settings directly. This article covers the first option. For more details about the second option and how to use it, please click here.
Using the Custom Error Documents option in Plesk provides a quick and simple way of creating custom-built error pages for your website. You just have to enable the option and insert your custom pages into the files provided. Although it is quick and simple - it does have some drawbacks. First, there are only five error messages covered:
For any other errors (although they are unusual), the default Apache error message will be used, and therefore will not be customised. Secondly, only HTML is supported. If you want to use a scripting languange (such as PHP), you will have to use the second method to redirect the requests to a script within the website. Finally, you must only use the files provided. The set-up of the permissions on the directory forbids you from adding extra files to or removing the existing files already there (this prevents the files from going missing).
The JAB Web Solutions website uses scripts for error messages, so we must use the .htaccess method. This allows the website to notify us of any errors (such as Page Not Found) directly via e-mail.
If you just simple want to provide a few custom error pages should any errors occur, the following method is the best option.
Before we edit the files, we must first switch on the Custom Error Documents option within Plesk:
With the option set, the domain's configuration file will be changed to use the domain's own files in the event of an error, rather than using the default (and rather plain) messages produced by Apache. To change them to your own version, you'll need to edit the contents.
All the files are under the error_docs/ directory for each domain, for example, if your domain is example.com, they can be found under: /var/www/vhosts/example.com/error_docs/. In total. there should be five files:
There are three methods available to change the files:
You can edit the files directly using an SSH terminal and a console-based editor. Use of the Linux console and it's associated programs is beyong the scope of this article. This method is only recommended if you are familar with a Linux console.
You can use any standard FTP client to upload the files. However, it's worth noting that due to the permission settings on the directory, this may be difficult if the program does not over-write the file. If it attempts to delete the file and then create a new one with the new contents, it will fail as you will not have permission to remove and add files within the error_docs/ directory. If this fails, you can either try another program to use the Plesk method below.
Throught Plesk, you can use the File Manager for each domain to view and replace the contents of each of the files:
As the Custom Error Documents option is enabled, any errors generated by the site will now be served by these files. You do not need to change any more settings.