Log in

Flea Circus Director [userpic]

Redirection of Blogger syntax to Wordpress Syntax

6th May 2011 (09:35)

Moving from Blogger to Wordpress has been rather more effort than I would have liked, one of the issues was the permalinks. Here's my comments on the solution I've come up with to ensure than my model engineering blog does not break when I move it across.

When a blog has been running for some time there will be people who have deep linked your various posts and pages. The search engines will have done the same. When you move to Wordpress you don’t want all these links to stop working and for you to disappear out of the search engines.

To fix this you will need to redirect the other URLs from the old syntax across to the new syntax.

A good tool to help with problem page redirects is the following:

This needs to be configured to handle the different types of page:
  • Search
  • Categories
  • Posts
  • Archives

The following configuration is based on are based on the following initial work of Voyagerfan5761.

I created a group called “Blogger” so I can see my links separately from any others I might setup. I did this as a wordpress redirect but I don’t see any reason why it could not be done as an apache redirection using the .HTAccess

Setup these links below before importing the links at the bottom.

I’m not sure what the last one does but I’ve seen it in the logs so I’ve redirected it to the home page so people don’t get a 404 error.

The final thing is to redirect those links where the blogger permalink is different from the wordpress link. Luckily when you use the blogger importer it stores the blogger permalink in the wp_postmeta table so we can extract this information to make some new redirections. This can be done with some help from phpmyadmin.

For these pages we are going to script a series of redirects similar to this

Login to PHPMyAdmin and select your wordpress database. Run the following SQL.

SELECT CONCAT('/([0-9]{4})/([0-9]{1,2})/',Replace(Right(meta_value,INSTR(Reverse(meta_value),'/')-1),'.html',''),'\.html(\?.+)?$') AS Source,Concat('/$1/$2/',p.Post_Name,'/$3') as Dest
FROM wp_postmeta AS m
INNER JOIN wp_posts AS p ON m.post_id = p.id
WHERE meta_key = 'blogger_permalink'
AND meta_value <> '' and post_status = 'publish'
and Replace(Right(meta_value,INSTR(Reverse(meta_value),'/')-1),'.html','') <> p.post_name

This will produce results with two columns which can be exported as a CSV file. You then import this file into redirection to handle all of those links. The import screen can be found on the “Options” page of the redirection plugin.

My site was on a custom domain so I don’t need to configure the blogspot URLs to redirect across to the new site. However if you do have a blogspot url then you can follow these instructions to configure blogger for redirection.