1. Knowledge Base
  2. >
  3. Results
  4. >
  5. Setup Custom Error Docs With Plesk on Windows

Setup Custom Error Docs With Plesk on Windows

 

In order to set up custom error pages in Plesk on a Windows server, please do the following steps:

Step 1: Turn On the Custom Error Pages

These examples are using Plesk 18. The steps will be the same for other versions of Plesk; however, the button locations may differ.

Before you can use custom error pages, you must first turn them on:

  1. Log in to Plesk.
  2. Click Websites & Domains from the left-hand menu.

    Plesk - Websites & Domains

  3. Locate the domain you wish to configure.
  4. Click on Hosting Settings under the domain you are configuring.

    Plesk - Hosting Settings

  5. Navigate to the Web scripting and statistics section, then check the box for Custom error documents.

    Plesk - Custom Error Documents

  6. Click OK.
  7. You will be taken back to the Websites & Domains page with a successful notification on top of the page.
    √  Information: The settings were successfully updated.

Once you have Custom Error Pages turned on, you can then edit the existing error documents, set them up, or create new ones.


Step 2: Configure the Custom Error Pages

Option 1: Editing an Existing Custom Error Page

The easiest way to create your own error page is to edit the ones already there.

  1. Click on the Website & Domains tab (if not already on that page).

    Plesk - Websites & Domains

  2. Click on the File Manager icon.

    Plesk - File Manager

  3. Within the Root directory, click the error_docs folder.

    Plesk - File Manager - error_docs

  4. Click on the error page you want to edit. For example, not_found.html.
     
  5. Use Plesk's built-in code editor to edit the error page.

    Plesk - Code Editor

  6. Click OK to save your changes.

Once saved, your changes will take effect. No additional steps are necessary.

Option 2: Using web.config File

In addition to configuring custom error pages in Plesk, the web.config file (a file that stores configuration information for websites in IIS) can be edited to configure custom error pages.

  1. Click on the Files tab and open httpdocs (or the document root for the domain you are configuring).

    Plesk - File Manager

  2. Locate then click on the web.config file to open it in the Plesk text editor.
    If no web.config file exists, create a new file named web.config and place the following text inside:
    <?xml version="1.0"?>
    	<configuration>
    	     <system.web>
    	        <customErrors mode="On"/>
    	    </system.web>
    	    <system.webServer>
    	        <httpErrors errorMode="Custom">
    	        </httpErrors>
    	    </system.webServer>
    	</configuration>
  3. Custom error documents can be added in the httpErrors section. The first step would be to add code that removes the preset error document.
    For example, to remove the preset 404 document, add the following code:
    <remove statusCode=”404” subStatusCode=”-1”/>
    Replace the number for the statusCode with the error code you wish to replace.
  4. After the preset error documents have been removed, the new error page can be added.
    404 error page example code:
    <error statusCode=”404”  path=”/path/to/error-file” responseMode=”ExecuteURL”/>
    For the path, use the relative path to the error file from your document root. For example: "/error_docs/NothingHere.html"
  5. The step above can be repeated for each error status code you would like a custom error page for.

Following all of the steps above with a blank web.config file would result in the following example web.config file.

<?xml version="1.0"?>
<configuration>
  <system.web>
    <customErrors mode="On"/>
  </system.web>
  <system.webServer>
    <httpErrors errorMode="Custom">
      <remove statusCode=”404” subStatusCode=”-1”/>
      <error statusCode=”404”path=”/error_docs/NothingHere.html” responseMode=”ExecuteURL”/>
    </httpErrors>
  </system.webServer>
</configuration>