When a user clicks on a link to a page that’s no longer available on your site, your server returns a 404(Page Not Found) error. This error takes place due to broken links or typo’s.

Of course you would not want to lose the visitor, so it’s best create a custom 404 page to provide more useful information about your site and lead the visitor back to your blog

404 Page

There are many ways to create custom pages and the easiest way is by adding Google search code which you can easily get from Google webmaster tool. This code does the following:

  • It adds a search box for your site with appropriate search suggestions.
  • It tries to provide alternatives to incorrect URLs.

This makes it easier for users to find the information they need (and makes it less likely that they’ll leave your site to look elsewhere.)

To add the widget to your custom 404.php page, copy the code below and paste it into your page between the <body> and </body> tags. Be sure to replace the URL http://www.example.com with the URL of your own site.

var GOOG_FIXURL_LANG = ‘en’;
var GOOG_FIXURL_SITE = ‘http://www.example.com’
<script type=”text/javascript”

You can check out my 404 page by visiting http://naeem.pk/error