Htaccess Error Document 404, 401, 500 Custom Page


First of all, you have to know what each error code means, the famous errors are 404, 401, 500.

  • Error 404: simply means the web page you are trying to access cannot be found on the web server.
  • Error 401: simply means unauthorized access or you need a valid user login to access the web page.
  • Error 500: means there is an Internal error on the server, or the problem is not with your internet connection or computer but with remote server.

On Apache server, you can configure of set the properties of each folder individually, you may need some custom design or style for 404 or 401 documents on your host for example to contain your company logo or your website header, just like big websites, you can accomplish this task by using .htaccess files.

The first step is to find if you have a .htaccess file on the directory or host you want to customize, if you already have one, we need to modify it, if you have not, you need to create a new one using Notepad, just open it and save a new file without name just put in file name field “.htaccess“, do not forget to choose “All files” in “Save as type” combo box.

create a new htaccess file using Notepad

After creating you new htaccess, you have to put you instructions and then upload it to your target directory, or usually to your host web root directory “/public_html“.

Setting custom Error document for 404, 401, 500

You can tell the Apache Server about your custom error document pages just by using the following simple instruction:

ErrorDocument 404     /404.html

This instruction means that when the error 404 fires, show the page 404.html to the visitor which is in the same folder where you put the .htaccess file . this will be applied also for 401 or 500 errors in the same way.

  1. No comments yet!, be the first to post a comment.

Your email will not be published, The required fields marked with '*'