One of the common messages users encounter while surfing the web is HTTP 404 error – The page cannot be found. This might happen when the web page has moved to a new location, web page is no longer available, or the user typed the wrong URL etc. Normally, the default browser page appears with the page not found message. A custom error message can also be setup that would present some options for the user and retain the user’s interest in your website. The error can be from the client or server; client error messages are prefixed with 4xx (e.g. 404, 400, 403 etc) and server error messages are prefixed with 5xx (e.g. 500, 501, 502 etc). This article outlines the client side error messages and specifically 404 errors.
- A search box can be included in the custom error page.
- Display couple of important links in your website including the Home Page, for the user to continue browsing.
- Simply redirect the user to the main page or any other page. This might, however, confuse the user as to the status of the requested page.
- Having a link to a site-map is a good option.
- Create a custom error page – Create a custom error page (e.g. error. htm) and include information you deem necessary. The options discussed above would give you an idea of the type of content to include. Even if you are having a custom error file, some browsers might still ignore the custom file and display its own message, if the file size is small. Ensure that your custom error file size is around 5K to avoid this.
- Modify .htaccess – The .htaccess is used, among other things, to process error messages using ErrorDocument command. This command takes an error code and an URL for redirecting the error. The .htaccess is normally found in the main root directory of your website. If there is no such file create one using a Text editor such as Notepad or Textpad and save it as .htaccess( include the dot). If there is an existing .htaccess, open it using a Text editor and suitably modify it. Make a backup of the existing .htaccess before editing as a wrongly written .htaccess may not display your website properly. Add the following line:
ErrorDocument 404 /error404.htmIn the above example, error404.htm is the custom error file placed in the root web directory (e.g. html or wwww etc.); 404 denotes the error code , File Not Found.Similarly, add a separate line for each error code. For example:ErrorDocument 401 /401.htm ErrorDocument 403 /403.htm
No related posts.

