Here’s a useful bit of Javascript that will redirect your old Blogger blog account to your new, self hosted WordPress blog account once you’ve imported all your old blogs.
It uses the search function in your new account to list the possible matches (usually just the correct one!). It works this way because the blog names on blogger are rarely the same as in wordpress, but it encourages people to update their links by showing them it’s different. It also displays a helpful message.
First go to your blogger account, select “Design” tab and “Edit HTML”. To get javascript in there, you’ll need to turn on “Expand Widget Templates”, and make sure any code is properly escaped, like the example below.
Now copy this piece of code, as is (except for line numbers), just after the Body tag:
- <h1>Blog has moved, searching new <a href='YOURBLOG'>blog</a>...</h1>
- <script type='text/javascript'>
- var splits = location.href.split("/");
- var splits2 = splits[splits.length-1].split(".");
- var search = splits2[0].replace( /-/g, "+" );
- window.location = "YOURBLOG/?s=" + search;
- </script>
Now replace YOURBLOG with the address to your blog (e.g. http://www.akademy.co.uk/blog )
Test it by going to one of your old Blogger blogs.
A helpful page at http://www.blogcrowds.com/resources/parse_html.php

Here’s a bonus one for WordPress to WordPress auto redirection.
Just change the old blog location to the new blog location. I’ve added a delay so anyone can see that it is redirecting and a message if the redirect doesn’t work.
Just paste everything from the next line into your header.php file just after the body tag. Then update the OLDADDRESS and NEWADDRESS bits.
<h1>Blog has moved, switching to new one automagically (please update you link!)…</h1>
<script type=”text/javascript”>
setTimeout(“switchToNewBlog()”,3000);
setTimeout(“alert(‘Switch over did not work. Goto: NEWADDRESS’)”,5000);
function switchToNewBlog()
{
var newLocation = location.href.replace(“OLDADDRESS”,”NEWADDRESS”);
window.location = newLocation;
}
</script>
Actually, this wordpress – wordpress relocation script is mich better:
Just put these lines at the very top of your header.php file and everything will automatically be redirected. Rankings on search engines should also redirect correctly with this:
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.akademy.co.uk" . str_replace( "blog-tips", "blog", $_SERVER['REQUEST_URI'] ) );
?>
Use the str_replace function to switch from one website to another. e.g.: if you are moving from”www.oldblog.com” to “www.new.com/blog” use str_replace( “oldblog.com”, “new.com/blog”, $_SERVER['REQUEST_URI'] );
Since this code will automatically redirect the blog to another, is there any code for redirecting the blog if only the homepage is open? cos from Google or Yahoo, i searched my own post (for testing), then it only show the specific html (post title) for a while before redirected to a new link. What I want is only the homepage is redirected. not the post in the blog. Help me!~
Hi Nadia.
You’ll need to check whether you are on the homepage and then redirect if you are something like:
- if( window.location.href == "your old blog home address" )
- window.location = "your new blog address"
- if( window.location.href == "your first address" || window.location.href == "your second address" )
- window.location = "your new blog address"
Note that some home pages can have several slightly different address such as : “http://www.akademy.co.uk/blog” and “http://www.akademy.co.uk/blog/index.php” – you’ll need to check for each one, just or them together:
Hope that helps.