Skip to main content

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:
  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

Popular posts from this blog

Strange problem occured while trying to create a CSV file using PHP Script - The file is not seen on FTP but can download using file's absolute path url

Strange problem occured while trying to create a CSV file - The file is not seen on FTP but can download using file's absolute path url Last day I came across a strange problem when I tried to create a csv file on therver using a PHP script. the script was simply writing a given content as a csv file. The file will be created runtime. What happened was, The script executed fine, file handler for new file was created and contents was wrote into the file using fwrite and it returned the number of bytes that was written.

How to get the Query string of a URL using the Javascript (JS)?

JS function get the Query string of a URL or value of each parameter using the Javascript(JS)? If you want to get your current page's url var my_url=document.location; to get the query string part of the url use like this: var my_qry_str= location.search; this will return the part of the url starting from "?" following by query string Lets assume that your current page url is http://www.crozoom.com/2013/page.html?qry1=A&qry2=B then the location.search function will return " ?qry1=A&qry2=B " to exclue "?", do like this:


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 »
Member
Search This Blog