Add Our Facebook App »

404 page – useful to readers & meaningful to (search engine)spiders

Written by Soumen Halder under Blogging

In my earlier post I showed how to build a user-friendly 404 error page for your blog. Now that we have learnt how to make it user-friendly we should now focus on making it search engine optimised. Because most of the 404 pages we create do not provide the necessary 404 header which could make search engines penalize you for duplicate content. Let me show how to prepare a 404 page that is useful to the readers as well as meaningful to the search engines.

The most popular options in a 404 page that are used in order to make it user-friendly are

  1. Providing some explanation to user for “ Why it happened ?”.
  2. Giving him some related links.
  3. Provide some helpful links.
    i. Go to the homepage.
    ii. Go back.
    iii. Contact Us. etc
  4. Providing him an option to search the blog.
  5. Redirect him automatically to the homepage.

The 1st option is what our default 404.php have. And earlier I’ve showed how to incorporate the options 2nd, 3rd ( Go to the homepage ) & 4th. In this post I’ll let you know how to provide the rest options as well as make it Search Engine Optimised. Follow the steps as described. Copy the mentioned codes & place them as instructed.

Redirecting to the homepage automatically :

1.     Copy the above code(meta tag) & place it between the header( <head>, </head>) tags.The “content=15“ means the page will be automatically redirected to homepage after 15 secs. You can also change the value if you wish.

<meta http-equiv=“refresh” content=“10;url=<?php echo $homeUrl;?>” />

2.     Now create an .htaccess file if there is none or edit it if you have it under your root folder. Put the following line at the end of the file.

ErrorDocument 404 /404.php

Make it Search Engine Optimized :

Add the following piece of code before your page coding starts i.e  before the <html> tag.

<?php
$homeUrl = ‘http://www.your-blog-address-here.com/’;
header(“HTTP/1.0 404 Not Found”); // This is the 404 header
$arPath = explode(‘/’, $_SERVER['REQUEST_URI']);
?>

Providing the ‘ Go Back ‘ And ‘ Contact Us ’ Link :

Copy the following code & then paste it with proper CSS( if you care for good design).

<li><a href=“javascript:history.back();”>Go Back Where You Came From</a></li>
<li><a href=“Your Contact page URL goes here”>Contact Us.</a></li>

Visit here to see for yourself how it works.

So now you have a user-friendly as well as a search engine friendly 404 error page. If you have any problem in understanding feel free to ask. I’ll be happy to help.

NB : If you don’t want the pain of doing the coding yourself feel free to download the 404.php with all necessary instructions. I’ve designed it for you.

Add Your Comment

All Comments are Moderated.

YOUR COMMENT



About This Site

Ampercent is a technology blog on computer tutorials, software guides, how to tricks and web tools. The blog is updated daily and written by two computer science students from India. Read More »



Subscribe to RSS Feed

Join Our Community

Submit Product For Review

Want a Software or a product to be reviewed ? Tell us about it, we will do the rest.