Custom 404 not found and so on…

December 18, 2007

We are familiar with 404 not found error. it happens when the requested file is not found. But we can customize this error message.

There are some other apache error codes. We can categorize few of them as follows

  • Client Request Errors
    • 400 - Bad Syntax
    • 401 - Authorization Required
    • 404 - Not Found - most common
  • Server Request Errors
    • 500 - Internal Server Error

To customize the error message we need to follow the following steps

  • First, create the HTML page (e404.php) that we want to use as your error message and save it into the home directory
  • Add the following line in the .htaccess file
    • ErrorDocument 404 /e404.php
  • These two files are stored in the home directory (/htdocs/e404.php, /htdocs/.htaccess)
  • Now lets test it . From the browser address bar request (http://localhost/invalidScriptName) for any script that are not eixsts physically and the custom messages will be shown that are used in the e404.php

Thanks
$haymoL
eXploRinG Apache

Entry Filed under: Apache. Tags: , , , , .

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Me in Brief

Expert Rating Certified Professional PHP5
Hi I am Shaikhul Islam Chowdhury Shaymol,
Currently working at Internet BS Corp as a Software Engineer.
I like to explore LAMP and other Web Technologies.
 

My LinkedIn Profile

View Shaikhul Islam Chowdhury Shaymol's profile on LinkedIn
 

Pages

Categories

Links

RSS PHP Magazine

RSS PHPGeek

Archives

Photos from FlickR

graduate

RoomMates@RashidHall.KUET

faruk monir monil n me

yamin me n tani apu

me@home

More Photos