Custom Error Documents / Plesk Method
Posted by Diego Cousinet on 14 December 2010 01:21 PM
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 language (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).
If you just simple want to provide a few custom error pages should any errors occur, the following method is the best option.
By default, the Custom Error Documents are enabled: 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:
If you have a virtual server (VPS) 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 beyond the scope of this article. This method is only recommended if you are familiar 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.
Through 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.