It is about technology!
 Subscribe to Feed

How I tweaked the 404 page

404errorIt may be a dead link, or a mistyped link or deleted page, image or any other media.

But it is true that web servers of Word Wide Web are busy returning “File Not Found” messages all round. It is part of the ecosystem. You can’t wish it away. After all, it is perfectly human to err, and continue to err.

So what can’t be cured may be endured in a more elegant way.

WordPress has made the process of rendering a “404 Error” page from out of the active theme itself without the need for creating one and assigning its path on the .htaccess file. You can spot a 404.php file in (almost) all themes. They are just bare-bones page merely announcing to the wanderer that he has lost his path and an error has occurred.

But 404 has much to offer. You can communicate the person who has strayed on to your site and convert his as a regular customer. There a plugin called “AskApache Google 404” which has many options including integrating Adsense. I’ll try that plugin and write a comprehensive review.

Recently Theme Hybrid ran a competition for the “coolest, smartest and funniest 404 page”.

On my part I tweaked the 404 Error page on this blog using the tricks enumerated in the WordPress Codex page.

I used a conditional tag to sense if the visitor mistyped the URL himself or followed a dead link and print a different message. In addition, an email will be sent to the admin (read, myself) if a dead link was spotted.

I made a slight modification to the code furnished in the WordPress codex page cited. Here it is:

#some variables for the script to use
#if you have some reason to change these, do. but wordpress can handle it
$admin_email = get_bloginfo(‘admin_email’); #the administrator email address, according to wordpress
$website = get_bloginfo(‘url’); #gets your blog’s url from wordpress
$websitename = get_bloginfo(‘name’); #sets the blog’s name, according to wordpress

if (isset($_SERVER[‘HTTP_REFERER’])) {
#setup a message to be sent to me
$failuremess = “A user tried to go to $website” . $_SERVER[‘REQUEST_URI’] . ” by clicking a link somewhere and received a 404 (page not found) error. “;
$failuremess .= “It wasn’t his fault, so try fixing it. He came from “.$_SERVER[‘HTTP_REFERER’];
$casemessage = “<br />I can’t blame you for this. The site administrator has been emailed about this problem.”;
mail($admin_email, “Bad Link To “.$_SERVER[‘REQUEST_URI’], $failuremess);

You can see it in action by clicking here: “Not Found“.

alternately, you can type fictitious URL on the browser to view a different message, which won’t accept any responsibility, at least overtly! 😉

Tags: , , , , , , , , ,

One Response to “How I tweaked the 404 page”

  1. Francis. T says:

    Very simple tricks but useful.

    Lucidly explained. Write more.


Leave a Reply

Copyright © HyperCircle 2009 | Powered by Wordpress | Designed by Elegant Themes