Set up a Custom Error Page

How Can We Help?
< Back
You are here:

You can create a custom error page and set up OpenLiteSpeed to display it for visitors who encounter errors (such as 404). This is how.

Configure OpenLiteSpeed Virtual Host

Through WebAdmin Console

From the WebAdmin Console, navigate to Virtual Hosts and press the configuration icon.

Navigate to General > Customized Error Pages and press the + button.

Select the appropriate Error Code (in this example, we are choosing 404 Not Found) and enter the URL to the custom error page.

Modifying the VH configuration file directly

If the OLS web Admin console is in read-only mode( such as on DirectAdmin), or you just prefer a command-line editor instead of web GUI, you can locate the virtual host configuration file and edit it directly through vi. You can add the following to the virtual host configuration. Of course, you will need to create the customized 404.html page at doc root.

errorpage 404 {
  url                     /404.html

Restart the Server

Save the setting and restart OpenLiteSpeed for the changes to take effect.

Now, whenever a visitor triggers a 404 error, the page will be redirected to 404.html.