Create branded error pages for a better user experience
Error pages are displayed when visitors encounter HTTP errors on your website. Instead of showing generic server error pages, you can create custom, branded error pages that provide helpful information and maintain your site's design.
cPanel provides special codes you can use in error pages:
<!--#echo var="HTTP_REFERER" --> - URL that linked to the error page<!--#echo var="HTTP_USER_AGENT" --> - Visitor's browser info<!--#echo var="HTTP_ACCEPT" --> - Content types browser accepts<!--#echo var="HTTP_HOST" --> - Your domain name<!--#echo var="REQUEST_URI" --> - Requested URL that caused error<!--#echo var="REDIRECT_STATUS" --> - HTTP status code<!DOCTYPE html>
<html>
<head>
<title>404 - Page Not Found</title>
<style>
body { font-family: Arial, sans-serif; text-align: center; padding: 50px; }
h1 { font-size: 72px; margin: 0; }
p { font-size: 18px; }
</style>
</head>
<body>
<h1>404</h1>
<h2>Oops! Page Not Found</h2>
<p>The page you're looking for doesn't exist.</p>
<p>Requested URL: <!--#echo var="REQUEST_URI" --></p>
<p><a href="/">Return to Homepage</a></p>
</body>
</html>Alternative method using .htaccess file:
ErrorDocument 400 /errors/400.html
ErrorDocument 401 /errors/401.html
ErrorDocument 403 /errors/403.html
ErrorDocument 404 /errors/404.html
ErrorDocument 500 /errors/500.html
ErrorDocument 503 /errors/503.htmlCreate corresponding HTML files in /errors/ directory.
Visit a non-existent URL on your site:
https://yourdomain.com/this-page-does-not-existWordPress automatically handles 404 errors using your theme's 404.php template. To customize:
Track 404 errors to identify and fix issues:
Create a temporary maintenance page via .htaccess:
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ /maintenance.html [R=503,L]
ErrorDocument 503 /maintenance.html
Header Set Cache-Control "max-age=0, no-store"Replace IP with your IP to allow your access during maintenance.
A good custom 404 page can turn a negative experience into a positive one. Include humor, helpful links, and make it visually appealing. Some of the best 404 pages become memorable parts of a site's brand.