Using .htaccess file you can easily change the default error pages that are being served by your web server. To use .htaccess to modify your web site error pages your server needs to be configured with AllowOverride FileInfo. Most web hosting servers are configured in such a way so having a custom error page instead of the default ones is possible.

Using a custom error page give you an option to keep your visitors on your site. For example you can have a link to your main page or even your complete site navigation included in the error document. In this even if a user get an error page he/she will be able to navigate to your site main page or some other section of your site. A custom error page always look better than the simple default error pages served by the hosting server.

So for example, let’s start with most common error page. The 404 error page:

ErrorDocument 404 /notfound.html

The line above tells the webserver to use a file named missing.html as error document.
Please note, the leading slash. It tells the browser that this file is located in your web site root folder. In case you miss the slash the webserver will look for a missing.html in the current directory. In case you do not have such a file a default 404 page will be server with a message that an additional error has occurred while trying to find the missing.html file you have defined in your .htaccess file.

If you wish to keep your site structure clean and organized, you can create a folder on your website and keep all custom error pages there. For example you can create a folder named “errors” and place all pages that are going to be used as error handlers there. With a subdirectory your .htaccess file will look like

ErrorDocument 404 /errors/notfound.html

Please, note that the ErrorDocument directive can only be used with local file paths.
This means that you cannot define an error document using full URL, such as:

ErrorDocument 404 http://www.example.com/errors/missing.html

The above line is wrong and will not be woring at all.

Also, when using custom error pages with images, CSS files, javascript files and other linked documents it is always a good idea to use full URL to link to these external files as when an error occurs in a subfolder the relative links will not work. For example if you have:

<img src=”images/badpage.jpg”>

it will only be working well for your website main folder.

To have it working on all levels of your site, it should be either:

<img src=”/images/badpage.jpg”>

or

<img src=”http://www.example.com/images/badpage.jpg”>

Another issue you should have in mind is the strange behaviour of Internet Explorer with error documents that are smaller than 512 bytes. Such error documents will not work properly in Internet explorer. It will replace them with the default IE error page. This issue is known as “Show friendly HTTP error messages” bug in IE. So our advise is always to design your missing pages to be bigger than 512 bytes.

Similar issue can be encountered with error pages that are CGI or PHP scripts (running as CGIs). With some web server configuration a PHP script set as error document may not work properly on IE, unless you send a HTTP 200 response to the browser. (strange issue, but it is happening). Please, note that the issue is only with Internet Explorer. The pages are working fine with FireFox, Netscape and other browsers.

So, now let’s have an example with some more error codes:

ErrorDocument 500 /internal_error.html
ErrorDocument 401 /authorization_required.html
ErrorDocument 403 /forbidden.html

As you can see from the example the ErrorDocument uses a simple syntax:

ErrorDocument  <error_code>   <path_to_file>

Where <error_code> should be replaced with the HTTP error you should assign a custom error page and the <path_to_file> should be replaced with the path to your own custom error page.

Here it is list of some common HTTP error codes:

400 Bad Request
The server received a request it cannot handle due to bad syntax for example

401 Unauthorized
Such an error will show up in case a user did not supply a proper login credentials when using the .htaccess based user/pass protection

403 Forbidden
The request page is forbidden. Such an error shows up when you have a Deny from directive

404 Not Found
As the error message says the page that you have requested cannot be found on the server.

410 Gone
The requested page have been removed permanently

500 Internal Server Error
The server encountered an error. Usually such error messages show up with CGI scripts. Also you can get such an error message when you have bad syntax in your .htaccess file.

Complete list of HTTP response codes can be found here:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

phpMyAdmin 3.4 disponible phpMyAdmin 3.4 es la nueva versión de este gestor de bases de datos web bajo la licencia GPL desarrollado para manejar MySQL. El lanzamiento de es...
mysqli character set name mysqli_character_set_name, mysqli->character_set_name — Regresa el conjunto de caracteres determinados por default para la conexión de base de...
Optimizacion de contenidos web Imagínate que estás en una recepción donde están ofreciendo canapes y bebidas. Un extraño cerca de ti inicia una conversación. Solo te lleva algunos m...
Line lanza un servicio de taxis para competir contra Uber, #Line Line ha presentado hoy en Japón un nuevo servicio bautizado como Line Taxi, que se integra en su aplicación oficial y de momento solo estaba disponibl...
LLega Office para Windows 10 Microsoft puso a disposición de los usuarios de la 'preview' de Windows 10 tres de las aplicaciones más importantes de su paquete de ofimática de form...
Mozilla es la empresa que genera mas confianza en Internet Los esfuerzos de La Funfación Mozilla por evitar que el comportamiento de sus usuarios en la web sea rastreado por parte de terceros han provocado que...
Adobe compra tecnología de cine a Iridas Adobe ha anunciado la compra de Iridas sin desvelar los detalles financieros del acuerdo. El software de vídeo de Adobe, Premiere Pro y After Effects,...
#whatsapp: La versión de WhatsApp para Android incluye el cifrado La versión de WhatsApp para Android incluye el cifrado punto a punto, de manera que solo emisor y receptor pueden acceder a los mensajes. Las críti...
Type Operators instanceof is used to determine whether a PHP variable is an instantiated object of a certain class: Example #1 Using instanceof with classes ...
Windows 8.1 incluirá viene con un gran rediseño! Un grupo de nuevas imágenes filtradas sobre la próxima actualización del sistema Windows 8.1 revelaron cambios de diseño para esta plataforma. Según e...