Error 404 (File not found) occurs when a user requests a document from the web server that is not on disk. That is, when a user requests a file that does not exist. This is the most “popular” of all errors. You can observe the occurrence of such errors in the error_log file and take this into account - track which documents on the server are “not found” and correct incorrect links from your html documents. Also, links to non-existent documents may come from other sites.

For the convenience of site visitors, you can handle 404 errors by replacing the standard responses of the web server with your own pages with the necessary description of the cause of the error and advice on what to do in this case. It is also useful to place a map of your site or a link to a search engine on such a page.

How to handle error 404. Create a .htaccess file in the www directory and place the following instructions for the Apache web server in it:

ErrorDocument 404 /not-found.html

Then create a not-found.html file in which you place a description of the error that occurred and advice on what to do in this case for your site visitor. Now a user who types the address of a non-existent page in his browser will be automatically redirected by the server to the not-found.html file.

Using the ErrorDocument directive, you can handle not only the 404 error, but also almost all other errors. For example, you can handle a 403 error this way.

Attention: a feature of the MS Internet Explorer browsers versions 5.xx and 6.xx is that if your error file is less than 512 bytes in size, the browser will show the user not your file, but its own 404 error message. The simplest solution In this situation, the error file is filled with spaces so that its size exceeds 512 bytes.

Hjalp dette svar dig? 27 Kunder som kunne bruge dette svar (145 Stem)