23 June 2013

How to redirect 404 Error/Page Not Found to homepage in Blogger

The Major mistake which most of the Bloggers commits is that They do not Set a Custom 404 error page to their Blog. By Default Blogger has a 404 error page but i suggest that sticking with this default 404 is not a good option for an newbie blogger as it is not user friendly and so your traffic drops down. Now let's find out how to solve this issue ?

What is a 404 Error ?


When a user lands to a nonexistent or deleted URL on your blog, Blogger will display this Error 404 (Page Not Found) i.e. “Sorry for the inconvenience, the page you are looking for has no existence”.
This may lead to loosing a blog readers.So to avoid loosing your reader you should either redirect reader to homepage or any post page when comes to a deleted or nonexistent page or post of your blog.
There may be ways to redirect 404 page to homepage. So here we gives you two simple methods by which you can redirect your user to your home page.
First one is redirection using meta refresh script and Second method is by using a simple JavaScript.

Tip: Personally i don’t recommend to add JavaScript because of it’s effect on loading time of your blog.

You can choose which is best from the below methods.

Meta Tag Refreshing Code ( Recommended )


  1. Take a Backup of your Blog in case anything bad occurs
    Go to Blogger Dashboard --› Select a blog --› Template tab --› Backup/Restore
  2. After Backup comes to Template tab --› Edit HTML
  3. Now find <head> tag using CTRL + F
    Copy and paste below code just below/after <head> tag

    <b:if cond='data:blog.pageType == &quot;error_page&quot;'>
    Oops! Page does not exist. We are redirecting you to home page.
    <meta content='5;URL=http://www.trickonics.com' http-equiv='refresh'/>
    </b:if>
  4. Note : Change http://www.trickonics.com with your blog homepage URL
  5. Finally save your template --› Done.


Using JavaScript


  1. Navigate  to Blogger Dashboard --› Select a blog --› Settings --› Search Preferences --› Custom Page Not Found ( under Error and redirections)
  2. Click Edit and paste below code :

    Sorry, the page you were looking for in this blog does not exist. You will be redirected to homepage shortly.
    <script type = "text/javascript">
    //Blogger 404 Redirect v1.0(trickonics.com)
    BSPNF_redirect = setTimeout(function() {
    location.pathname= "http://www.trickonics.com/"
    }, 5000);
    </script>
  3. Note : Change http://www.trickonics.com/ with your blog homepage URL  and 5000 is the delay time in Milliseconds.You can change it to any value. Changing the value to Zero (0) would redirect immediately. (no delay)
  4. Finally Click Save Changes --› Done.
You can check the status of this 404 page by going to a URL that doesn't actually exist like www.your-blog.com/404.html

1 comments :

  1. tery maa Noo Lan
    Koti Dy Putar Tery Maa Ny chooot

    ReplyDelete