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:

400 Bad Request;

401 Unauthorized;

403 Forbidden;

404 Not Found; and

500 Internal Server Error.

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).

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:

bad_request.html (400);

forbidden.html (401);

internal_server_error.html (500);

not_found.html (404); and

unauthorized.html (403).

There are three methods available to change the files:

SSH

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.

FTP

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.

Plesk

Through Plesk, you can use the File Manager for each domain to view and replace the contents of each of the files:

First, log onto the Plesk Control Panel (all details can be found in the 'Account Details' e-mail, dispatched to you when your account is activated).

Then go to the System Page > File Manager

You will then be shown the contents of the home directory for the domain, including the httpdocs/ and httpsdocs/ directories for the main files of the website. From this list, click on error_docs/.

Plesk will now show you the files in the error_docs/ directory. The first option is the '..' entry, which, when clicked, will return you to the last directory you just views. The remaining five entries are the five files for the error documents.

For each file, to the far-right is a set of three icons. You need to click the middle one to edit the file.

Via the next page, simply copy-and-paste the contents of the HTML page into the textbox and click Save.

Do this for each file to complete the set.

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.