Error Handling 404 Not Found The requested URL



Imagine a situation: imagine a visitor goes to your site clicks on the link, a window opens ... And suddenly - sees in one - a message in a pale default background: Not Found
The requested URL /somepath/pivo.html was not found on this server.
Apache/1.3.X Server at www.some.net Port XX
Not Found
The requested URL /somepath/pivo.html was not found on this server.
Apache/1.3.X Server at www.some.net Port XX

This phrase, so much talking to the visitor without the knowledge of English, are automatically generated by the server if the requested document with the URL www.some.net/somepath/pivo.html, which is not on the server. Causes? Link broken or outdated bookmarks. Or the visitor typed the address manually and ochepyatka out. Or beer over ...

Particularly polite in such cases, webmasters do not like to scare the user pale technical text, and create a file server directory .htaccess (if it is not already there), and placed back row: ErrorDocument 404 /path/error.html

And now the server is in all cases 404 ( "document not found") gives the visitor harvested diligent web designer page error.html. On this page in the company for life style authors apologize (which is worse than the whole links, but better than nothing), explained to the visitor that the requested page is not here and now what to do with it. For example, to complain to email the webmaster about bad service or go to the home page of the resource. Some very advanced stick on the same error.html small search engine or site map ...

If your web hosting allows you to use SSI (server-side includes) or php, you can not only apologize but also to remind the visitor what it is "no beer" (if the visitor has already managed to get lost in the open windows on your site, and to focus not He remembers with a page link brought him to the "Error 404"). And ask him to send the webmaster has already prepared an error message.

For this file error.shtml (* .shtml - a standard file extension, which will be processed by the server for SSI-instructions) should contain: <p>Извините, пива марки &quot;<!--#echo var="REQUEST_URI"-->&quot;нет!</p> <p>Пишите в <a href="mailto:[email protected]?subject=error404&body=<!--#echo var="REQUEST_URI"--> not found; link from <!--#echo var="HTTP_REFERER"-->">Книгу Жалоб</a>. Вебмастера уволят.</p> = "REQUEST_URI" -! <p>Извините, пива марки &quot;<!--#echo var="REQUEST_URI"-->&quot;нет!</p> <p>Пишите в <a href="mailto:[email protected]?subject=error404&body=<!--#echo var="REQUEST_URI"--> not found; link from <!--#echo var="HTTP_REFERER"-->">Книгу Жалоб</a>. Вебмастера уволят.</p> from <p>Извините, пива марки &quot;<!--#echo var="REQUEST_URI"-->&quot;нет!</p> <p>Пишите в <a href="mailto:[email protected]?subject=error404&body=<!--#echo var="REQUEST_URI"--> not found; link from <!--#echo var="HTTP_REFERER"-->">Книгу Жалоб</a>. Вебмастера уволят.</p> HTTP_REFERER" -> "> <p>Извините, пива марки &quot;<!--#echo var="REQUEST_URI"-->&quot;нет!</p> <p>Пишите в <a href="mailto:[email protected]?subject=error404&body=<!--#echo var="REQUEST_URI"--> not found; link from <!--#echo var="HTTP_REFERER"-->">Книгу Жалоб</a>. Вебмастера уволят.</p> <p>Извините, пива марки &quot;<!--#echo var="REQUEST_URI"-->&quot;нет!</p> <p>Пишите в <a href="mailto:[email protected]?subject=error404&body=<!--#echo var="REQUEST_URI"--> not found; link from <!--#echo var="HTTP_REFERER"-->">Книгу Жалоб</a>. Вебмастера уволят.</p>

Solution using php (if your hosting provider is): written in the .htaccess

  ErrorDocument 404 /path/error.php 

In error.php file body (default * .php-files are processed for php-instructions), respectively: <p>Извините, файл &quot;<? echo $REQUEST_URI ?>&quot; не найден...</p> <p>Пишите в <a href="mailto:webmaster@ some.net?subject=error404&body=<? echo $REQUEST_URI ?> not found; link from <? echo $HTTP_REFERER ?>">Книгу Жалоб</a>. Вебмастер исправит.</p> <p>Извините, файл &quot;<? echo $REQUEST_URI ?>&quot; не найден...</p> <p>Пишите в <a href="mailto:webmaster@ some.net?subject=error404&body=<? echo $REQUEST_URI ?> not found; link from <? echo $HTTP_REFERER ?>">Книгу Жалоб</a>. Вебмастер исправит.</p> ; link from <? echo $ HTTP_REFERER?> <p>Извините, файл &quot;<? echo $REQUEST_URI ?>&quot; не найден...</p> <p>Пишите в <a href="mailto:webmaster@ some.net?subject=error404&body=<? echo $REQUEST_URI ?> not found; link from <? echo $HTTP_REFERER ?>">Книгу Жалоб</a>. Вебмастер исправит.</p>

In both (* .shtml and * .php) cases, the user will see an apology; and if the clicks on the link above «mailto:», in his e-mail client window will appear filled with the error message: what is not, from this "what is not" link.

Notes: Basically, anything you can not do the above listed. Let them learn English! ...