Tumblr to WordPress Import – Maintaining Links

Starting Life - jimdeane

I recently migrated away from Tumblr, as I found that Tumblr was heading more towards micro-blogging – reducing the size of the posting editor (seriously? LOOK AT THE PROPORTIONS) which made embedding code snippets or writing more lengthy posts pretty arduous. As an unapologetic geek – WordPress seemed like the natural choice.

The Tumblr to WordPress Import Process did a reasonably good job of importing everything – but I wanted to make sure to not lose the (already indexed/linked) URLs. Unfortunately this wasn’t quite as easy – as defining custom permalinks on a per-post basis in WordPress appears to still be manual (via an .htaccess). To resolve this generically (without having to make a new alias for the mammoth amount of posts I had (ahem), I simply set the permalink format to the name of the post (which follows the same format as tumblr) and defined the following RedirectMatch regular expression in my htaccess:

RedirectMatch permanent ^\/post\/(\d+)\/(.*)$ /$2

From a URL such as:

https://alexsmith.org/post/36766766992/cors-headers-in-nginx

This will isolate:

cors-headers-in-nginx

and (permanently) redirect it to:

https://alexsmith.org/cors-headers-in-nginx

and, as such, play nicely with search engines.

Photo Starting Life by jimdeane (CC)

2 Replies to “Tumblr to WordPress Import – Maintaining Links”

  1. Aha, thanks!

    The long-time officially recommended WordPress plugin for this function has been abandoned and no longer seems to work. Your code was just what I needed!

Leave a Reply

Your email address will not be published. Required fields are marked *