Home  »     »     »     »     »     »  How to automatically redirect the blogger 404 error page to search page based on the keywords in failed url?

How to automatically redirect the blogger 404 error page to search page based on the keywords in failed url?

Tuesday, January 21, 2014



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:
  1. How to redirect old blogger blog links to a new web address with out affecting the search traffic? 
  2. How to create a blogger landing page which will redirect to other pages based on the query string? 
  3. How to add Facebook Like button in Blog? 
  4. How to add Google PlusOne (g +1) Button on blogger pages?  
  5. How to add BlogIt button or Widget on your blogger website 
  6. How to escape HTML scripts and JS codes for placing in blogger templates  
  7. Redirecting the blogger 404 error page to search page results?   
  8. Articles on Blogger tools, features and tips



How to link to this page?
If you wish to link to this page from your website, simply Copy and paste the above HTML code to your web page. It will appear on your page as:
How to automatically redirect the blogger 404 error page to search page based on the keywords in failed url?.




Share this!




comments powered by Disqus

This Weeks 7 Popular Posts


Subscribe to Recent Posts by Email
Stay connected to CROZOOM with regular Email notices of new Techie articles and IT Jobs. Updates will be delivered to your Inbox as soon as they are posted online.

Enter Your Email Address:  

Delivered by FeedBurner   RSS Feed

Search this Blog   



Urgent Openings for PHP trainees, Andriod / IOS developers and PHP developers in Kochi Trivandrum Calicut and Bangalore. Please Send Your updated resumes to recruit.vo@gmail.com   Read more »