Free Blogger blogs serve as the starting point for a lot of bloggers. Most of the serious ones then move to self-hosted WordPress blogs. It makes sense to move as you have more control and can optimize it better for SEO.
How do you make sure that you do not lose any existing traffic when you move from Blogger BlogSpot to WordPress? There are many tutorials on how to customize your Blogger and WordPress sites to allow proper redirection of old Blogger URLs to your new WordPress site. However, most of these have there weaknesses.
Blogger redirects all BlogSpot URLs to local country-specific domains. For instance, if you are visiting a BlogSpot blog http://myblog.blogspot.com from India, the URL would get redirected to http://myblog.blogspot.in
For proper and effective global redirection of BlogSpot blogs to self-hosted WordPress site, you need a better and improved code. I created a simple WordPress plugin to ensure proper redirection of Blogger blogs to new your WordPress blog.
Steps to set up redirection of Blogger blog to self-hosted WordPress blog include four not-so-difficult steps.
- Set up your WordPress blog and importing content from Blogger using the Tools -> Import menu in the WordPress dashboard.
- Customize your Blogger BlogSpot blog template to allow redirection.
- Add code in WordPress blog to handle URLs being redirected from old Blogger blog.
- Create a page with title “Redirect”
1. Importing Blogger posts to WordPress
WordPress is equipped to handle import of Blogger content. It’s a simple click to go process.
To start the Blogger importer, go to Tools → Import → Blogger.
For WordPress versions 2.0.2 to 2.6.5, go to Manage → Import → Blogger.
2. Set up redirection in old Blogger blog
Log in to your Blogger account and go to the Template option of the blog. In the new Blogger interface, you can find it in a dropdown menu.
Revert to “classic template” to find the HTML Template box. Just paste the following code into that text box. Make sure to replace “speckygeek.com” with your own WordPress website URL address.
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en” dir=”<$BlogLanguageDirection$>”>
<head>
<title><$BlogPageTitle$></title>
<script type=”text/javascript”>
<MainOrArchivePage>
window.location.href=’http://speckygeek.com/’
</MainOrArchivePage>
<Blogger><ItemPage>
window.location.href=’http://speckygeek.com/redirect/?q=<$BlogItemPermalinkURL$>’
</ItemPage></Blogger>
</script>
<MainPage><link rel=”canonical” href=”http://speckygeek.com/” /></MainPage>
<Blogger><ItemPage>
<link rel=”canonical” href=”http://speckygeek.com/redirect/?q=<$BlogItemPermalinkURL$>” />
</ItemPage></Blogger>
</head><body>
<div style=”border:#ccc 1px solid; background:#eee; padding:20px; margin:80px;”>
<p>This page has moved to a new address.</p>
<h1>
<MainOrArchivePage><a href=”http://speckygeek.com”><$BlogTitle$></a></MainOrArchivePage>
<Blogger><ItemPage>
<a href=”http://speckygeek.com/redirect/?q=<$BlogItemPermalinkURL$>”><$BlogItemTitle$></a>
</ItemPage></Blogger>
</h1>
</div> </body></html>
<!– replace speckygeek.com with your WordPress website URL —>
3. Add code to your WordPress site
Now you need to make sure that your WordPress website can handle the Blogger redirect URL properly and forward it to the correct page. The following is a simple plugin for handling the redirection.
Install it on your WordPress site using the Plugins -> Add New -> Upload option. Activate it.
Here is the plugin code for your reference. You can also copy-paste it to a new php file, says, blogger-redirect.php, and upload that as the plugin.
<?php
/*
Plugin Name: Blogger Redirect
Plugin URI: http://xtrapunch.com
Description: For blogger to WP redirection. Just add a page with permalink URL slug as “blogger” or “redirect”, or just keep its title as “Blogger” or “Redirect”. Your WordPress permalink should match your blogger URL structure. Blogger redirection URL should be set as http://yoursite.com/redirect?q=your-old-blogspot-url
Author: Xtrapunch
Version: 1.0
Author URI: http://xtrapunch.com
*/
function p2h_red() {
if ( is_page (‘blogger’,’redirect’) ) {
global $wpdb;
$old_url = “http://”.$_SERVER[‘HTTP_HOST’].$_SERVER[‘REQUEST_URI’];
$permalink1 = explode(“blogspot”, $old_url);
$permalink2 = explode(“/”, $permalink1[1]);
$permalink2 = “/”.$permalink2[1].”/”.$permalink2[2].”/”.$permalink2[3];
$q = “SELECT guid FROM $wpdb->posts LEFT JOIN $wpdb->postmeta “.
“ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE “.
“$wpdb->postmeta.meta_key=’blogger_permalink’ AND “.
“$wpdb->postmeta.meta_value=’$permalink2′”;
$new_url = $wpdb->get_var($q)? $wpdb->get_var($q) : “/”;
wp_redirect( $new_url, 301 );
exit;
}
}
add_action(‘wp’,’p2h_red’);
?>
Advantages of this Blogger to WordPress redirection code:
- Handle redirection from all localized Blogger blog addresses. Eg: myblog.blogspot.com, myblog.blogspot.in
- No need to worry about the permalink structure of the WordPress blog
After installing the WordPress plugin, just activate it from the Plugins -> Installed Plugins menu.
4. Create a new page with Redirect as the title
As the last and final step, create a new page and have the title as “Redirect”. Publish the page. The purpose of calling the page “Redirect” is to have the page slug as “redirect” because the Blogger redirection URL uses this address.
That’s it. Test your old Blogger URLs to see it is properly functioning. Even if you change your permalink structure later, you do not need to worry about redirection. Using the plugin also allows you to change your WordPress themes freely without having to customize the new WordPress theme for redirection code.
Moving Blogger RSS Feed
When you move your blog to WordPress, your feeds will also change. You need to redirect your old Blogger feed to WordPress.
Go to Blogger -> Settings -> Site Feed -> Custom Feed. Now add your WordPress RSS feed address, which would be your website URL followed by “/feed/”. Now, your Blogger feed will automatically point to the new WordPress feed. If you use FeedBurner, you don’t have to worry about this part. Just log in to your FeedBurner account and update the feed URL to reflect the new WordPress feed URL. All done now.
I would love to hear from you about this WordPress plugin. If you face any problem, just let me know by leaving a comment here or email me.