Setting a 404 Error Page via the .htaccess File


Step - 1 Login to your cPanel.
 

Step - 2 Under the Files section click on File Manager.



Step - 3 Navigate to the document root folder for the site.

Step - 4 Click on Settings.




Step - 5 Ensure Show Hidden Files is selected.  


Step - 6 Then click Save.

Step - 7 Right click on the .htaccess file and select Edit.



Step - 8 If the .htaccess file didn't exist in the previous step, click on New File at the top left, name the file .htaccess, and set the directory for creation to /public_html/ or the document root of your site. 



Step - 9 You might have a text editor encoding dialog box pop-up, go ahead and just click Edit.  



Step -10 Now that you are ready to edit the .htaccess file, the simplest way to set a 404 error page is by directly setting a 404 error message in the .htaccess file itself:


ErrorDocument 404 "<H1>Page not found</H1>" 


If you already have a static HTML page that you'd like to use for 404 errors you can also direcly point to that file with the .htaccess file as well:


ErrorDocument 404 /404.html 

Step -11 After you've made your edits, click on Save Changes, and you should see a green Success pop-up 
 

Step -12 Now if you try to pull up a page that won't exist on the server such as /ThisPageWon'tExist you should see the custom 404 error message that we've configured. The first image below is the default 404 error page when a custom one is not set, and on the second one is our custom one that we've just created: