2010/04/15

Customising Error Pages

No matter whether you are a geek or simply a normal internet user, there are times when you come across dead links within a website. And that pretty much annoys you. And half of the time you decide to move on and go to other websites.

To the webmaster/web owner, this is a downright frustration as well because you loses traffic. But maybe you do not realise that the reason why your visitor decides to leave your website not because they can't access the page (well, that's half of the reason of course) but because they're being rubbed in the face with the ugly ERROR page. Pokoknya, ilang minat bisdia.

So, to make sure the visitors will still stay on your website, you need to spiff up your error pages supaya inda boring, inda membari meluat. What do we do?

Obviously, we will need to customise the error pages. To do this, you will have to create a file called.htaccess. If you already have this file, you only need to add in a couple of lines.



Anyway, if you hadn't, follow the steps below.

Step 1:

Create two files that serve as your error pages. You can customise it in anyway you like. Add in CSS kah, Flash kah, up to you. Save them as 404.html and 403.html respectively. (You can choose to have them as .php files instead of .html if you like).



Step 2:

Open up your editor (Notepad kah, Wordpad kah) and type in these lines:

ErrorDocument 403 http://www.yourwebsite.com/403.html
ErrorDocument 404 http://www.yourwebsite.com/404.html


Save the file as htaccess.txt

* If you had chosen to name the files as 404.php and 403.php, make sure in the lines above you use the same extension as well.



Step 3:

Upload all the three files (404.html, 403.html, htaccess.txt) to the root folder of your website and rename htaccess.txt as .htaccess



Test the error pages by typing in your web address URL followed by garbled/random words, for example: yourwebsite.com/antamtiaeh. The error pages that you created just now should be popping up. If it doesn't, do give me a buzz.