Set up a Custom Error Page

You are here:
< Back

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.

Create Custom Error Page

Create a custom error page and visit the URL to make sure it works.

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.

Through modifying the VH configuration file directly

If OLS web Admin console is in read-only mode( such as on DirectAdmin), or you just prefer 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 cause, 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 in order for the changes to take effect.

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