In this article we will discuss how to set up a custom 404 not found errror page via 1) a .htaccess file for Apache linux server and 2) web.config file for IIS Windows Server.
For the good SEO and positive user-experience with our website, custom 404 error pages are usually required. There are many benefits to Website having a 404 not found custom error page for users and SEO.
We know search engines want to index and show best results for their users. so they don’t like to index that page which does not exist.
The 404 HTTP error code tells search engines to not index that page – because the page or URL is invalid and creates a poor search experience for the users on Web.
So having 404 error page will help search engines what to index and crawl pages of your website that are useful to users; thus creating a positive search experience.
.htaccess rule for Apache server to set custom 404 page
In .htaccess file The ErrorDocument tells the Web server to load the home page for any 404 or “File Not Found” errors.
let’s play with your website and hit comment if you have any query.
ErrorDocument 404 http://www.domain.com/404.html
Web.config rule for Windows Server to set custom 404 page
Windows IIS server uses the httpErrors in web.config file for the handle 404 not found error and redirect user to custom page.
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.php" responseMode="ExecuteURL" />
To use this its required to set capability at the application level is turned off by default for IIS.
let’s play with your website for set custom 404 not found error page and hit comment if you have any question. Thanks,