How to Create Custom 401 and 404 Error Pages for Your Website
When a web server receives a request from a browser that it doesn’t know how to process, it typically returns one of several error messages to the visitor’s browser window. Two of the most common errors are
401 Unauthorized Access: This message gets displayed when people attempt without permission to access web pages that are password protected.
404 File Not Found: This message appears when visitors click a broken hyperlink or type an incorrect web address in the browser’s address bar.
You can customize these messages to match the design of your website, and with a little help from your host provider, you can have these custom error pages installed and in service on your domain within 24 hours or less after transferring the site files to the remote server.
The 401 Unauthorized Access page usually includes a short message to visitors along with the refresh meta tag that redirects visitors to the home page or some other location on the web after a specified number of seconds.
The meta tag goes in the head of the page and should be formatted like this:
<meta http-equiv="refresh" content="10;URL=http://www.yourdomainname.com">
The message can say anything you like, but typically, it says something like this:
You have attempted to access a page for which you are not authorized. This page will automatically redirect to the [INSERT DOMAIN NAME] Home Page in 10 seconds or click the following link to manually redirect this page to [INSERT DOMAIN NAME].
The 404 File Not Found message provides more space for a customized message and any additional information such as marketing and advertising, but generally should state something like this:
The page you are seeking cannot be found: The page you are looking for might have been removed, had its name changed, or is temporarily unavailable. Please try the following: * If you typed the page address in the Address bar, make sure that it is spelled correctly. * Open the www.DOMAINNAME.com home page, and then look for links to the information you want. * Click the Back button to try another link.
To customize your own 401 and 404 error pages, create two new web pages based on existing pages on the completed site. This ensures that the new pages use the same layout and graphics as the rest of the site. Save these files with the filenames error401.html and error404.html, and then edit the content areas for both pages by using the preceding examples.
If desired, add more information to suit your site’s particular needs. For example, rather than just displaying the URL of the home page on the 404 error page, why not also include links to all the pages on your site, similar to your site map page? The same technique would also work for the 404 error page.
The customized content is entirely up to you, so be as creative and helpful as you can to the visitors (potential customers) that will be viewing these pages.