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.
One 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:
- Go to Settings > Search preferences > Custom Page Not Found (under Errors and redirections).
- 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>
- The top is the message. You are free to change it.
- To redirect to a page/site other than your homepage, replace
pathname
withhref
, 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).
- 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"
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.
Thanks for such a useful post..
waiting for this.. i ll check this works for me. THanks
Very nice! Thanks so much.
I added a line break between the two message sentences. (
)
i will try this very soon thx
Nifty, thanks!
on my blog it will not work, please check http://www.coloureddust.com.pl/
@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 == "error_page"'>
<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.
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?
that's really a great post and i like the way you write the content..
thanks. this is the solution to my problem. now I am satisfied.
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...
@tec kop
Make sure you enter the correct code. Copy and paste to avoid mistakes.
Thank you for this tip. I will use it on my blog. :-)
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
the widget doesn`t work ...while redirecting it is going on redirecting to the same page..
my blog is http://www.needonetouch.org
I use custom blogger template, but its not work on my blog. Are there any way to use it.
Thanks!
Hi,
I would like to redirect certain posts under a particular label only but not all the posts. Is it possible? Thanks
thank you very very much brother......
Thanks for this How-to article.
I've pasted the code and all is done.
thank you very much....
@happy.cottage
I'm afraid that's not possible.
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.
thanks very much....
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 :)
Thanks for the info...It's really helpful. I've done it! It's work!!
Very nice .... Thanks BloggerSentral ...... keep the good work up ....
thnx it's working fine with me :)
thank you very much....
This is badass. Thanks.
Great, working perfectly.
Working great,
thanks for sharing
I had a lot of problem with this redirection. Thank you bloggersentral that I finally found it. It helped me alot.
Regards,
Yelis Yengkhoiba
Thanks for the tip worked a charm
Thank you so much!!! This post is a lifesaver esp to a new blogger like me
thanks .It's so great with my blog
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
Good article, I will try to apply on my blog?
WOW !!! THANKS A LOOOTTT !!! i've been searching for this for hours, it almost ruined my day, until i found your blog,
Thanks a lot for the trick. It helps every newbie.
Thanks bro..
Thanks for the code. I added an image in between the codes. Works great.
Thans alot.. I had the same problem like Arbal and now its fixed... keep it up!
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.