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
Before you can use custom error pages, you must first turn them on:
- Log in to Plesk.
- Click Websites & Domains from the left-hand menu.
- Locate the domain you wish to configure.
- Click on Hosting Settings under the domain you are configuring.
- Navigate to the Web scripting and statistics section, then check the box for Custom error documents.
- Click OK.
- 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.
- Click on the Website & Domains tab (if not already on that page).
- Click on the File Manager icon.
- Within the Root directory, click the error_docs folder.
- Click on the error page you want to edit. For example, not_found.html.
- Use Plesk's built-in code editor to edit the error page.
- 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.
- Click on the Files tab and open httpdocs (or the document root for the domain you are configuring).
- 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>
- 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”/>
- 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”/>
- 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>