How to create a custom 404 page
Help centreOn this page
This guide shows how to set up your own page for visitors who land on an address that doesn’t exist on your site, either with the Error Pages tool in cPanel or with one line in .htaccess.
What a 404 page is
When someone follows a broken link or mistypes an address, the server answers with code 404, meaning “not found”. Without a custom page, the visitor sees a bare grey message with no way back to your site. A page of your own keeps them on your site and gives them somewhere to go next. For the other codes you might see, read what website error codes mean.
Using WordPress?
Skip the rest of this guide. WordPress handles missing pages itself and shows the 404.php template from your theme. To change it, look in your theme’s settings first, as many themes let you pick a page to show. Otherwise edit the template in a child theme, or use a plugin built for custom 404 pages. A 404 page set in cPanel won’t be used by WordPress.
Option 1: cPanel Error Pages
- Log in to cPanel.
- In the Advanced section, open Error Pages.
- If you have more than one domain, pick the right one from the Managing list.
- Click 404 (Not Found).
- Type or paste your page into the editor. Plain HTML works fine. The buttons above the box insert tags such as the address the visitor asked for.
- Click Save.
cPanel saves the page as 404.shtml in the domain’s document root (usually public_html) and tells the server to use it.
Option 2: an ErrorDocument line in .htaccess
Use this if you’d rather design the page yourself and upload it like any other file.
- Create your page, for example
notfound.html, and upload it topublic_html. See how to upload files with File Manager or FTP. - In cPanel, open File Manager and go to
public_html. - Click Settings and tick Show Hidden Files (dotfiles), so you can see
.htaccess. - Right-click
.htaccessand choose Edit. If the file isn’t there, click + File to create it. - Add this line at the top and click Save Changes:
ErrorDocument 404 /notfound.html
Start the path with a forward slash, so it works for missing pages in subfolders too. Don’t put a full web address (with https://) here. If you do, the server sends a redirect instead of a 404, and search engines may treat broken links as real pages.
Make a copy of .htaccess before you edit it, so you can put it back quickly if the site stops loading.
What to put on the page
Keep it short and helpful. A good 404 page has:
- A plain message. “Sorry, we can’t find that page” is enough. Avoid jokes that leave people unsure what happened.
- Your normal header and menu, so it looks like part of your site and people can carry on browsing.
- A link to the home page and to your most visited sections, such as products, prices or contact.
- A search box, if your site has search.
- A way to report the problem, such as a link to your contact page.
Use full paths starting with a slash for images, CSS and links (for example /images/logo.png). Relative paths break when the missing address sits inside a folder that doesn’t exist.
Test it
Visit an address that you know doesn’t exist, such as https://yourdomain.co.uk/this-page-is-missing. You should see your new page. To check the server still returns a 404 code rather than 200, use your browser’s developer tools (the Network tab) or an online header checker.
If it doesn’t work
- You still see the default page. Clear your browser cache or try a private window. Check the
ErrorDocumentline is spelled correctly and the file name matches exactly, including capital letters. - The page shows but looks broken. Your images or stylesheet use relative paths. Change them to start with
/. - The whole site shows a 500 error after editing .htaccess. A typo in the file is the usual cause. Put your copy back, or remove the line you added. How to find error logs in cPanel shows where the exact fault is recorded.
- Old pages have moved rather than vanished. Set up a redirect instead, so visitors and search engines go straight to the new address. See how to redirect a page or website in cPanel.
Still stuck? Open a support ticket and we’ll help.
Every plan has cPanel, free SSL, backups every six hours and free migration.