How do I set-up custom error pages in Plesk?


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


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.


Setup


Before we edit the files, we must first switch on the Custom Error Documents option within Plesk:



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

  • If you have logged on at the Client Level (this is the default level), please click on the name of the domain you wish to update. This will load the domain's settings page.

  • Now click on the Setup icon.

  • Under Services, enable the tick-box for Custom Error Documents to tell Apache to use the files in the error_docs/ directory.

  • Click OK to save the settings.


Files


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:



  • 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


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.


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


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



  • Follow the same process as above to log onto Plesk and view the domain settings page. However, instead of clicking on Setup, click on 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.

  • 161 Users Found This Useful
Was this answer helpful?

Related Articles

How do I set-up custom error pages in Plesk?

There are two different ways to display error messages using Plesk on Linux. The first is...

How do I set-up custom error pages using .htaccess?

There are two different ways to display error messages using Plesk on Linux. The first is through...

What is Hotlinking and how do I prevent it?

If you notice a surge in the traffic coming to your site, it may not be because you are receiving...

What is an injection-based Spam attack?

Many of the older techniques for sending Spam out via remote servers either involves searching...

How do I create a cron job?

A cron job (run by the cron daemon, or cron service) is a request for the server to run a...