How to Create a Custom Error Page on your website

This is a very common thing to do, but most people find it difficult to actually achieve.This is because probably you’ve not been pushed in the right direction or maybe you haven’t thoroughly gotten the hang of it.Designing on the web should be fun not stressful.So to make it more easier especially for newbies, it’s best things are explained in the simplest manner.

If you’re running a LAMP server of basically just a Linux server/Apache server/Parallel server, it should come with a control access for you to be able to write out some scripting codes that can actually run some functions on the server. Normally each server has it’s own default error documents which pops up once an error is committed.

Such as a 404 Error popping out when you type an incorrect URL on your browser. E.g www.yourweb.com/control → Correct, but instead you type: www.yourweb.com/conrtol → wrong. These are some of the mistakes that can pop up an error document. To effectively use the code below, make sure that the size exceeds more than 512bytes, because on IE, if the size of the .htaccess file doesn’t exceed that amount of bytes above, IE will show it’s own error document instead of your custom error pages.


###################################
      ##
      ## HTACCESS CONTROL MODULE
      ## USED TO REDIRECT/DYNAMICALLY
      ## CONTROL URL's ON A WEBSITE
      ## ADD AS MUCH COMMENT HERE TO
      ## MAKE THIS FILE LARGER THAN 512BYTE
      ###################################
       Options +FollowSymlinks
       RewriteEngine on
       RewriteRule ^(.*)\.htm$ $1.php [NC]
       # custom error documents

       ErrorDocument 404 /404.php
       ErrorDocument 403 /403.php
       ErrorDocument 500 /500.php

Remember to save your file name as “.htaccess” and upload to your server.place the .htaccess together with the custom Error documents that you’ve designed to suite your need in the same root folder or If it’s not in the same root folder, you can specify it by adding the link in the .htaccess file appropriately. E.g


 # see how i've added a directory to the error document
     ErrorDocument 404 /errorpage/404.php
       ErrorDocument 403 /errorpage/403.php
       ErrorDocument 500 /errorpage/500.php

The Error documents that should be created, depends solely on the number of error document you want your users to see once an error occurs.

Example: Error documents can be created with any extension, in this case, am using (dot*PHP) extension as you can see in the example above. Doing this will eventually pop out your very own custom error page once an error is encounter on your Server.

0

About sarah

Contributing to the information World makes it easier for others to have knowledge about other information's. My ideas and knowledge on the Internet and in Computer Science, has brought me a step closer to having logical understanding of things and i feel knowledge is power and with that anyone can become somebody special. Learning is a step to perfection, i'll try my best to make sure i represent that part of the information everyone seeks...
This entry was posted in Programming, Tutorial and tagged , , , . Bookmark the permalink.

One Response to How to Create a Custom Error Page on your website

  1. Pingback: Customerror web | Seifen

Leave a Reply

Your email address will not be published. Required fields are marked *

Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar