Knowledgebase: Umbrellar Support
How to create your Custom Error files?
Posted by Sinan Esen on 07 September 2015 05:18 PM

Overview. 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
  • 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 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:

  • bad_request.html (400)
  • forbidden.html (401)
  • internal_server_error.html (500)
  • not_found.html (404)
  • unauthorized.html (403)


There are two 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.

(0 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).