Mod your 404 page of your WordPress blog
Wordpress automatically creates pretty 404 pages, but why stop there, Whats the use of pretty 404 pages ? Read on to mod your blog to boast your SEO and provide more interactivity to your user.
Whenever a webserver cannot serve you a particular page, due to non-existence of that page, the server returns you a 404 response error.
WordPress Blog automatically redirects to a pretty “Page not found” page, if there is a 404 error i.e either the entered URL is not valid or that post/page does not exist. Well WordPress does half the job for you. In general its always good to have a pretty “Page not found” page,
Why pretty 404 pages are good ?
Well, Pretty 404 pages have added benefits as they tell a visitor, that what they are looking for could not be found, in a very friendly way, rather than showering them with some server mumbo jumbo which they won`t be bothered to look at. This also helps in keeping the user hooked to the site, cuz we don`t want to loose a visitor, we need to get one
.
Some measures which should be taken in terms of making your visitor stay and SEO of your site. ( The following points are listed by Google)
- Tell visitors clearly that the page they’re looking for can’t be found. Use language that is friendly and inviting.
- Make sure your 404 page uses the same look and feel (including navigation) as the rest of your site.
- Consider adding links to your most popular articles or posts, as well as a link to your site’s home page.
- Think about providing a way for users to report a broken link.
- No matter how beautiful and useful your custom 404 page, you probably don’t want it to appear in Google search results. In order to prevent 404 pages from being indexed by Google and other search engines, make sure that your webserver returns an actual 404 HTTP status code when a missing page is requested.
- Use the Enhance 404 widget to embed a search box on your custom 404 page and provide users with useful information to help them find the information they need.
- Use the Change of Address tool to tell Google about your site’s move.
404 Pages tend to reduce your page score so always keep in mind to remove em or make sure they don`t get indexed with any search engine.
Some pretty neat examples of good 404 designs.
How WordPress can help you ?
Pretty 404 pages generated by WordPress are good enough, but why waste the potential of WordPress when it can give your blog a lil more interactivity and SEO boost. To get the maximum of your blog and make sure that the user stays in your blog, There are two things.
Step 1 : Install AskApache Google 404 plugin for your WP blog
If you haven`t added this plugin yet, do add it ASAP. AskApache Google 404 plugin.
This plugin uses some AJAX code, Google Search API’S, and a few tricks to display a very helpful and Search-Engine Optimized Error Page
Step 2 : Add the following code in 404.php inside your theme folder
Just add the following function wherever you want to display the message in 404.php of your theme folder. This function allows your WordPress blog to automatically email you or the admin of your site whenever a user stumbles upon a 404 page. (Modified Source from WordPress Docs)
<?php
$adminemail = 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 wordpressif (!isset($_SERVER['HTTP_REFERER'])) { ?>
Sorry, tried accessing
<?php
$message = "Please don`t mind,";
} elseif (isset($_SERVER['HTTP_REFERER'])) {
echo "You tried clicking ";$failuremess = "A user tried to go to $website".$_SERVER['REQUEST_URI']." and received a 404 (page not found) error. ";
$failuremess .= "User came from ".$_SERVER['HTTP_REFERER'];
mail($adminemail, "$website : Bad Link To ".$_SERVER['REQUEST_URI'], $failuremess, "From: $websitename <noreply@$website>"); #email you about problem
$message = "An administrator has been emailed about this problem, too.";#set a friendly message
}
echo $website.$_SERVER['REQUEST_URI']; ?> and it doesn't exist. <?php echo $message; ?> Try searching below.
Alternative to Step 2
If you are unable to perform Step-2, just download the following plugin if-404-email-me.zip (11)
Extract to plugins directory, activate it and open 404.php located inside your theme folder. Add the following function wherever you want the pretty text to be displayed
<?php if(function_exists(if_error_send_mail)) if_error_send_mail(); ?>
Conclusion
Voila, you have successfully modded your 404 page. I am open to queries, so don`t hesitate, post your comments


















0 Responses to “Mod your 404 page of your WordPress blog”