Setup 404 Handler Using .htaccess

PHP have one great file called .htaccess file. With this file you can do lots of stuff which you might have not imagine.

In this post I will show you the trick to set up the 404 handler using .htaccess file.

What is 404 Handler?

404 handle is just like a fallback page, which should be display when user visited the page which is not exists.

How to set 404 handler?

For setting up the 404 Handler, you just need to perform two simple steps.

First is to create a file which handles the 404 error and place/upload this file to the root of your server.

Now place below code in your htaccess file.

ErrorDocument 404 /404.php
ErrorDocument 404 /404.php

So from above code you can see that 404.php will be served when 404 Not Found occures.

So Easy :)

Related Posts

Written by Avinash

Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.

View all posts by: