Monday 3 February 2014

How to redirect 404 page to Homepage




Hello Friends, In the previous post we had learnt about setting a custom 404 page for our blogs and in this post we will learn how to auto redirect our 404 pages to the homepage. We will be using a short javascript code for redirecting the 404 pages to homepage after displaying a custom 404 page. A custom 404 page makes your blog more user frindly because it lets you show a custom message when ever a user come accross a URL that is not present in your blog or has been shifted.

redirect 404 to homepage


You need not to remove your 404 pages, we will be delaying the redirect a little bit so that a user can get to look at your 404 page and then he will be redirected. You can also append a message for redirection in the page we have created before. Now, let us check out how to add this redirection code in the blogger.

Recommended Articles:

How to add a redirect in 404 page in blogger:

  • Login in to your Blogger account.
  • Navigate to your dashboard and click on Settings.
  • Click on “Search Preferences” as shown in the image below.
  • Now add the following JavaScript code in the box highlighted in red in the image below.
<script type = "text/javascript">
JN_redirect = setTimeout(function() {
location.pathname= "/";
}, 5000);
</script>
  • Now click on save and you are done.

You have successfully added a redirection in your 404 error page. Now, whenever a user come across a url that is not present in your blog will be shown 404 page and will be redirected to your homepage.

I hope you enjoyed reading this blog post, You can check out more blogging and SEO related articles in our blogging tips and tricks section.
 If you like my work; you can show your regards by hitting Facebook like button, following us on Google+ or Twitter, stumbling our posts on stumble upon or giving us a link back via the links below. Stay tuned for more update.

Do you like this post? Please link back to this article by copying one of the codes below.

URL: HTML link code: BB link code:
author pic
Author: Mohammad Zafar Ahmad
Zafar Ahmad is PHP/Java Developer and a Passionate Blogger. He likes to write about Blogging tips, SEO tips, Blogger Widgets, Smart phones, Tablets and Online Earnings. You can find him on Facebook, Twitter or Google+

No comments:

Post a Comment