Saturday, June 3, 2023

Fixed 2023: why & how to redirect all 404 error pages to homepage on blogger blogspot?

 Find out how to immediately redirect all 404 error pages to homepage on blogger blogspot:


So i was just surfing the internet and asking myself how to solve the 404 errors for no longer existing or permanently deleted blog posts and if redirecting all urls which generate a 404 error to homepageUrl would solve this problem or not. 
There is too many answers to how to redirect all urls that generate a 404 error to home page. Two of these answers are :
- Redirecting 404 error pages to home page using a javascript code (custom redirect);
- Redirecting 404 error pages to home page using a meta tag (for blogspot templates);

1 - how to redirect 404 error pages to home page using a javascript code?

a - Go to your blogger dashboard first;
b - Click settings;
c - Scroll down to the Errors and Redirect tab;
d - Click Custom  404;

f - copy and past the javascript code as show below (see the images):

<script>
Souhailweb_redirect = setTimeout( function() {

location.pathname= "/"

}, 0 );
</script>

* note that you can replace the time value "0" to whatever you wants (10000 means 10 seconds and so on).
note that the pathname value could be whatever page you want to redirect 404 error pages to ( ex: location.pathname="/p/contact.html"




2 - how to redirect 404 error pages to home page using a meta tag (on blogspot)? :

this is how to do a redirect to your home page on blogspot blog, :
a - Go to your blogger dashboard first;
b - Click "theme";
c - Find and Click "Edit HTML";



d - Copy and past the meta tag code below in your theme between the <head> tags under the canonical url meta tag or the rss meta tags or so:

<b:if cond='data:blog.pageType == &quot;error_page&quot;'>
<meta content='0;url=/' http-equiv='refresh'/>
</b:if>

note that you can replace the time value "0" to whatever you wants (5 means 5 seconds and so on).
note that the "url=" value could be whatever page you want to redirect 404 error pages to ( ex: content='0; url=/p/contact.html')
 
Is it what you was looking for?
Post your comments, reviews or recommendations below. This post would be more helpful and complete with your participations.
Thank you everyone.

0 Comment:

Post a Comment