When visitors hit a 404 (page not found), 403 (forbidden), or 500 (server error) page on your website, they see a generic server error page by default. You can replace these with custom pages that match your site's design, keep visitors engaged, and guide them back to working content.
Add an ErrorDocument directive to .htaccess
Create a custom HTML page (like 404.html), upload it to your public_html directory, and add this line to your .htaccess file:ErrorDocument 404 /404.html
Now when visitors hit a missing page, they see your custom page instead of the default server error.
01. Custom Error Pages via .htaccess
The ErrorDocument directive in your .htaccess file tells Apache to serve a specific page when a particular HTTP error occurs. This is the most common and flexible method.
Step 1: Create Your Error Pages
Create HTML files for the errors you want to customize. At minimum, create a 404.html page since that is the error visitors encounter most often. Save these files in your public_html directory.
Step 2: Add ErrorDocument Directives
Add the following lines to your .htaccess file in public_html:
ErrorDocument 400 /400.html
ErrorDocument 401 /401.html
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html
You only need to include the error codes you have created pages for. If you only want a custom 404 page, just add that one line.
You can also use a short text message instead of a file path: ErrorDocument 404 "Sorry, this page does not exist." (note the opening quote with no closing quote - this is the correct Apache syntax for inline messages). However, a dedicated HTML page gives you much more control over the appearance.
Step 3: Test It
Visit a URL that does not exist on your site (like yourdomain.com/thispagedoesnotexist) and verify your custom 404 page appears instead of the default.
Make sure the path in your ErrorDocument directive starts with a forward slash (/) and points to a file that actually exists. If the error page itself is missing, Apache will show a bare-bones "additionally, a 404 error was encountered" message, which looks worse than the default. For more on .htaccess, see our Complete Guide to .htaccess.
02. Custom Error Pages via cPanel
cPanel includes a built-in tool for creating custom error pages without manually editing .htaccess:
- Log into cPanel at my.ultrawebhosting.com
- Go to Advanced > Error Pages
- Select the domain you want to customize
- Click on the error code you want to customize (e.g., 404)
- Enter your custom HTML in the editor
- Click Save
cPanel provides several template tags you can use in your custom error pages, such as [url] (the URL that triggered the error), [ref] (the referring page), and [server_name] (your domain name). These are inserted automatically when the error page is displayed.
03. Common Error Codes to Customize
- 400 Bad Request - The server could not understand the request. Usually caused by malformed URLs or corrupted browser data.
- 401 Unauthorized - The page requires authentication (like password-protected directories). See How to Password Protect a Directory.
- 403 Forbidden - The server refuses to serve the page. Often a permissions issue. See 403 Forbidden Error.
- 404 Not Found - The page does not exist. This is the most common error visitors encounter. See Error 404 - File Not Found.
- 500 Internal Server Error - A server-side error occurred. See Error 500 - Internal Server Error.
04. Best Practices for Error Pages
- Match your site's design - Use the same header, footer, colors, and fonts as the rest of your site so visitors know they are still on your website.
- Include navigation - Give visitors a way to get back to your homepage, popular pages, or a search function. A dead-end error page means a lost visitor.
- Keep it simple and helpful - Tell the visitor what happened and what they can do about it. "The page you were looking for does not exist. Try searching, or go to our homepage."
- Avoid redirecting error pages - Do not redirect 404 errors to your homepage. Search engines need to see the 404 status code to know the page does not exist. Redirecting turns it into a "soft 404" which is worse for SEO.
- Use absolute paths for assets - In your error page HTML, use full URLs or root-relative paths for CSS, images, and JavaScript. Relative paths may break because the error page can be triggered from any URL path.
05. WordPress Error Pages
WordPress handles 404 errors through its theme system. Most WordPress themes include a 404.php template file that controls the 404 page. You can customize this by editing the file in Appearance > Theme File Editor, or by creating a 404.php file in a child theme.
WordPress automatically serves its 404 template for any URL that does not match a post, page, or other content type. You do not need an .htaccess ErrorDocument directive for WordPress 404 pages.
For 403 and 500 errors, WordPress does not have built-in templates. These are handled at the server level, so you would still use the .htaccess method described above.
Need Help With Error Pages?
If you are seeing frequent errors on your site and need help diagnosing the cause, our support team can review your server logs and configuration.
Open a Support TicketQuick Recap
- Create custom HTML error pages - At minimum, create a 404.html page
- Add ErrorDocument directives to .htaccess -
ErrorDocument 404 /404.html - Or use cPanel's Error Pages tool - Advanced > Error Pages
- Match your site design - Include navigation so visitors can find their way back
- Do not redirect 404s to your homepage - Let search engines see the proper 404 status
Helping users create professional error pages · Last updated March 2026 · Browse all Error articles
