How to redirect Blogger 404 Error (Page Not Found) to homepage

When a user goes to a nonexistent URL on your blog, Blogger will display this Error 404 (Page Not Found) message at the top of your blog post area:

"Sorry, the page you were looking for in this blog does not exist."

Hmm… probably not the best first impression you’d want to give a potential reader. Before  the user hits the Back button or closes the browser’s window/tab and disappears forever, you might want to redirect the page to your homepage (or to a page of your choice) where the chances of him/her staying and reading is (presumedly) far greater.

Blogger 404 error page not found redirectOne of the ways to redirect is to use meta refresh, but the problem with this method is it breaks navigation (it wont go back to the page you came from when you hit Back button). The better method is by using Javascript, and I think I’ve found the simplest way to do this on Blogger.

It is wise to include these two components in the redirection process:

  • Redirection message - to inform that the page doesn’t exist and the user is about to be redirected. Failure to do so will make the user feels cheated when the searched information is nowhere to be found on the landing page (homepage). Here’s an example:

    "Sorry, the page you were looking for in this blog does not exist. You will be redirected to homepage shortly.”

  • Time delay - to provide sufficient time for the user to read the message prior to redirecting.

Based on the above example, this is how you add the new message and the redirect script to your blog:

  1. Go to Settings > Search preferences > Custom Page Not Found (under Errors and redirections).
  2. Click Edit and paste this:
    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 by GreenLava(BloggerSentral.com)
    BSPNF_redirect = setTimeout(function() {
    location.pathname= "/"
    }, 5000); 
    </script>

    404 page not found redirect

    • The top is the message. You are free to change it.
    • To redirect to a page/site other than your homepage, replace pathname with href, and / with the URL of the page/site.
    • The number 5000 is the delay in milliseconds. You can change it to whatever value you think appropriate. Zero means immediate redirect (no delay).
  3. Click Save changes.

To test simply enter any URL that doesn’t exist in your domain/subdomain (e.g. http://yourblog.blogspot.com/dfsfgd) and see if your new Page Not Found message appears, followed by redirection after 5 seconds.

If you find any bugs/side effects, please let us know in the comments.

Enjoy!

44 comments to "How to redirect Blogger 404 Error (Page Not Found) to homepage"

Unknown October 19, 2012 at 7:33 PM    

I was using blogger custom redirect manually but now this is awesome way to solve 404 error.But i have few query.Is it good to redirect so many broken links in terms of seo?Because when i applied to adsense they rejected me and one of the reason for this was large number redirets.

mit thakkar October 19, 2012 at 7:39 PM    

Thanks for such a useful post..

Selva October 19, 2012 at 8:04 PM    

waiting for this.. i ll check this works for me. THanks

Tom October 19, 2012 at 8:58 PM    

Very nice! Thanks so much.
I added a line break between the two message sentences. (
)

adetruna October 19, 2012 at 9:21 PM    

i will try this very soon thx

Unknown October 19, 2012 at 10:17 PM    

Nifty, thanks!

ARBAL October 20, 2012 at 12:28 AM    

on my blog it will not work, please check http://www.coloureddust.com.pl/

Greenlava October 20, 2012 at 1:56 AM    

@ARBAL
I notice you are using Simply Faster template. I intentionaly removed the status message tags from the template. (Maybe I shouldn't have done that).
Anyway you can put it back. Find this code:

<b:includable id='status-message'>
<div id='page-header'>
<b:if cond='data:blog.pageType == "archive"'>
<div>Archive » <data:blog.pageName/></div>
</b:if>
<b:if cond='data:blog.searchLabel'>
<div>Category » <data:blog.pageName/></div>
</b:if>
</div>
</b:includable>

and replace it with this one:

<b:includable id='status-message'>
<b:if cond='data:blog.pageType == &quot;error_page&quot;'>
<b:if cond='data:navMessage'>
<div class='status-msg-wrap'>
<div class='status-msg-body'>
<data:navMessage/>
</div>
<div class='status-msg-border'>
<div class='status-msg-bg'>
<div class='status-msg-hidden'><data:navMessage/></div>
</div>
</div>
</div>
<div style='clear: both;'/>
</b:if>
<b:else/>
<div id='page-header'>
<b:if cond='data:blog.pageType == "archive"'>
<div>Archive » <data:blog.pageName/> </div>
</b:if>
<b:if cond='data:blog.searchLabel'>
<div>Category » <data:blog.pageName/></div>
</b:if>
</div>
</b:if>
</b:includable>

Tell me if it works. I'll do the same to Simply Faster template if it does.

ARBAL October 20, 2012 at 2:05 AM    

helped! it works! Check out the www.coloureddust.com.pl/wededed

In another topic I have a problem with the comments feature REPLY is not working at allblog:
http://www.coloureddust.com.pl/2012/09/desk-working-lamp-velleman-vtlamp6.html

Can you help?

Unknown October 20, 2012 at 1:23 PM    

that's really a great post and i like the way you write the content..

Blogger Tools October 24, 2012 at 3:18 PM    

thanks. this is the solution to my problem. now I am satisfied.

Anonymous,  November 2, 2012 at 10:59 AM    

the widget doesn`t work ...while redirecting it is going on redirecting but not going to homepage...need a help...if you want you can search my blog url..so that you can solve my problem..thank you...

Greenlava November 2, 2012 at 5:36 PM    

@tec kop
Make sure you enter the correct code. Copy and paste to avoid mistakes.

Ishmael F. Ahab November 7, 2012 at 5:57 PM    

Thank you for this tip. I will use it on my blog. :-)

Fluorescent Tube Recycler November 8, 2012 at 3:41 PM    

Is there a way to redirect a specific NON existing or saved as a draft http://xyz.blogspot.com/2008/11/about.html to another URL or to a new location at
http://www.abcd.com/about/ ?

is there a way to redirect another specific NON existing http://xyz.blogspot.com/2008/12/SECONDPOST.html to a new location at
http://www.abcd.com/SECONDPOST/ ?

etc.

thx

Unknown November 11, 2012 at 8:48 PM    

the widget doesn`t work ...while redirecting it is going on redirecting to the same page..
my blog is http://www.needonetouch.org

TGS November 12, 2012 at 10:13 AM    

I use custom blogger template, but its not work on my blog. Are there any way to use it.

Thanks!

happy.cottage November 16, 2012 at 1:14 AM    

Hi,

I would like to redirect certain posts under a particular label only but not all the posts. Is it possible? Thanks

rahul sethi November 19, 2012 at 5:00 AM    

thank you very very much brother......

Himanshu Pandey November 19, 2012 at 6:56 PM    

Thanks for this How-to article.
I've pasted the code and all is done.

Unknown November 22, 2012 at 2:14 AM    

thank you very much....

Greenlava November 22, 2012 at 2:19 PM    

@happy.cottage
I'm afraid that's not possible.

Jamie Pullman November 23, 2012 at 2:33 PM    

Wow! nice idea, it really holds and pull back our potential customers to the home page. This simple procedure is very useful for many of the bloggers.

wisudana November 24, 2012 at 4:36 PM    

thanks very much....

Bootstrap Business Blogger November 26, 2012 at 5:01 AM    

You are the man! You just saved me a hell of a lot of time, I was changing all the info on all my 275 youtube vids because url's got changed on my blogger standalone pages. This fixes everything :)

Sukma November 27, 2012 at 5:14 PM    

Thanks for the info...It's really helpful. I've done it! It's work!!

Anonymous,  December 4, 2012 at 11:23 PM    

Very nice .... Thanks BloggerSentral ...... keep the good work up ....

Anonymous,  February 15, 2013 at 4:56 AM    

thnx it's working fine with me :)

asaborneo April 2, 2013 at 2:50 PM    

thank you very much....

Annabelle April 6, 2013 at 3:53 AM    

This is badass. Thanks.

Freshers jobs April 9, 2013 at 11:26 AM    

Great, working perfectly.

Freshers Job India April 11, 2013 at 4:19 PM    

Working great,
thanks for sharing

Unknown May 26, 2013 at 3:56 AM    

I had a lot of problem with this redirection. Thank you bloggersentral that I finally found it. It helped me alot.

Regards,
Yelis Yengkhoiba

Unknown May 30, 2013 at 10:13 AM    

Thanks for the tip worked a charm

Unknown May 31, 2013 at 4:01 PM    

Thank you so much!!! This post is a lifesaver esp to a new blogger like me

Anonymous,  June 16, 2013 at 12:33 PM    

thanks .It's so great with my blog

Adedotun Adesanmi June 23, 2013 at 2:18 AM    

I personally search for this topic and made do with, though I don't have error page yet but this will be very necessary for fututr problem or error page

chyardi July 5, 2013 at 12:14 AM    

Good article, I will try to apply on my blog?

Ferdi Aziz July 27, 2013 at 11:20 AM    

WOW !!! THANKS A LOOOTTT !!! i've been searching for this for hours, it almost ruined my day, until i found your blog,

Play Angry Birds Online September 3, 2013 at 1:02 PM    

Thanks a lot for the trick. It helps every newbie.

Unknown September 5, 2013 at 10:56 PM    

Thanks bro..

notesonindianhistory September 18, 2013 at 11:35 PM    

Thanks for the code. I added an image in between the codes. Works great.

Unknown October 13, 2013 at 9:56 PM    

Thans alot.. I had the same problem like Arbal and now its fixed... keep it up!

Kabar Makkah December 10, 2013 at 5:58 AM    

thank's man !!!

Post a Comment

We love to hear from you! Leave us a comment.

To ensure proper display, HTML/XML/Javascript need to be escaped first using this escape tool.