Create Your Own Error Pages (Linux Webhosting)
Please use the “Print” function at the bottom of the page to create a PDF.
In this article, you will learn how to create your own error pages for your website visitors.
You can make it easier for your visitors by replacing the standard error messages sent by the server with your own error pages. As an example, we will show you how to set up an error page for the error message 404 (Not Found).
Please Note:
Custom error messages apply to all of the domains in the package where the website is located.
- Create a file named .htaccess and add the following content:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /error_404.html
ErrorDocument 404 /error_404.htmlYou can also enter another error number instead of 404 (see Frequent HTTP Error Messages). In this case, the corresponding error is intercepted. The error_404.html file contains the error message you redesigned.
- Create a file named error_404.html and paste the following content:
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Error 404</title>
</head>
<body>
<h3>This should not have happened. The page you requested does not exist (anymore).</h3>
<p><a href="index.html">Go to the Home page.</a></p>
</body>
</html Place the files .htaccess and error_404.html in the root directory of your website. After a few minutes, the changes take effect, and the new error message appears if the corresponding error occurs.