How to automatically redirect the blogger 404 error page to search page based on the keywords in failed url?
Blogger allows user to show a customised 404 (page not found) error page. You can add contents for your 404 error page through your blogger admin.
Do the following steps:
Login to Your blogger account
Select your blog
Click on "Settings" on the left side menu
Click on "Search Preferences" ( Settings >> Search Preferences )
Go to the "Errors and redirections " section
- Here on the given textarea you can add the contents for your customised Page not found page.
- The text area accepts a maximum of 10,000 Characters.
- You can add html code in this text area.
Let us do a trick to redirect the 404 Error page to a search page which lists records that matches the keywords found on the failed url. Here a javascript function which gets the urls page identifier and redirects the page to the search page by appending the keywords to the search url.
Copy the below given script, paste it to the "Errors and redirections >> Custom Page Not Found" text area and Save it.
<br><br>
<b style="font-size:15px;color:#000000">Page Not Found!</b><br>Sorry, the page you requested is not currently available. Please use the <b>SEARCH</b> option of website.
<br><br>
<a href="http://techqube.blogspot.com"><b style="color:red">VISIT HOME PAGE</b></a>
<br><br>
<script>
function getpageUrl()
{
var pagelink="";
var myurl=document.URL;
myurl=myurl.replace("http://","");
myurl=myurl.replace("https://","");
var st_n = myurl.lastIndexOf("/");
myurl=myurl.replace(".html","");
myurl=myurl.replace(".","");
if( st_n > -1 ){
var firstcharloc=st_n+1;
var lastcharloc=firstcharloc+200;
pagelink= myurl.slice(st_n,lastcharloc);
}
if(pagelink!=""){
pagelink=pagelink.replace("/ /g","%2B");
pagelink = pagelink.replace(/-/gi,' ');
pagelink = pagelink.replace(/_/gi,' ');
document.location.href="http://www.techqube.blogspot.com/search?q="+pagelink+"&search=Search&max-results=20&by-date=false";
}
}
getpageUrl();
</script>
Please don't forget to replace "techqube.blogspot.com" with your blog address :)
Related posts:
- How to redirect old blogger blog links to a new web address with out affecting the search traffic?
- How to create a blogger landing page which will redirect to other pages based on the query string?
- How to add Facebook Like button in Blog?
- How to add Google PlusOne (g +1) Button on blogger pages?
- How to add BlogIt button or Widget on your blogger website
- How to escape HTML scripts and JS codes for placing in blogger templates
- Redirecting the blogger 404 error page to search page results?
- Articles on Blogger tools, features and tips