I recently transferred my blog from a self hosted WordPress install to here, Posterous. The import went perfectly minus a few formatting issues, but when I went to transfer my domain, I found all my links (search engine/backlinks) didn’t work.
After a quick email to support, it became clear that Posterous doesn’t offer a 301 redirect service to ensure all links point to the right places.
I decided to find a way to take care of this for me. My old WordPress blog ran at http://www.deanbarrow.co.uk, I pointed my new Posterous blog to http://deanbarrow.co.uk. All my incomming links still pointed to the original domain, http://www.deanbarrow.co.uk.
So I needed to redirect all links from www. to the non www. domain. WordPress links are formatted like the following:
And Posterous is formatted like:
Tags and Categories: /tag/TAG
Now I could either painfully create a load of .htaccess rules, or create PHP script to sift though my old posts and automatically redirect users.
Obviously, I chose the latter..
The script I created must be named index.php and put in the root of your old domain (http:www.deanbarrow.co.uk).
You must rename your exported WordPress XML to ‘export.xml’ and put this in the same folder.
All that’s left to do is set the $new_url variable to the address of your new Posterous accout.
The script should do the rest. All posts, tags and categories will be redirected to your new blog automatically. Anything else will be redirected to the root of your new site.
It’s recommended you leave the script live for a number of weeks/months until search engines have updated their records. If you have a lot of active backlinks, you may want to leave it running permanently.
It’s worth noting that WordPress pages are not redirected, this wasn’t added because I didn’t need the functionality. This can easily be added though as the source is well commented.
Another point to note is that this script is designed to catch all inputted variables so you will need to leave your WordPress mod_rewrite rules in place.
The script can be found on Github - https://github.com/deanbarrow/Random-Scripts
Hopefully Posterous will add a 301 redirect service for imported blogs in the future and make my script redundent but for now, this is the best way to keep your WordPress links when transferring to Posterous.
As my site was small, I wasn’t worried about the inefficient looping involved in the script, if you have a larger website it might be worth dumping the export into a sqlite database then looking up the requests through queires. This shouldn’t be too hard to create.
Alternatively, with a few slight modifications, you could make the script list every 301 redirect, you could then put these in your .htaccess file (or nginx configuration) for a more efficient redirect. Just modify the redirect function to output something like ‘Redirect 301 /$request /$url’ instead of headers.
This is a just a quick script I wrote which is specific to my circumstances and needs, I do not gaurantee it will be 100% compatible with your export!