If you have a Tumblr blog on a custom domain and want to migrate the content and inbound links somewhere else, this small script is for you.
You'll need a Heroku account to set up the app, and all of your Tumblr posts hosted somewhere else with the same slugs as on Tumblr.
-
Clone this repository:
```
git clone [email protected]:martinmelin/tumblr-redirect.git ```
-
Create a new Heroku app from this repository:
```
cd tumblr-redirect heroku create ```
If you get an error when running the second command, you need to make sure you have the Heroku toolbelt set up correctly on your machine.
-
Configure the URL you want to redirect to:
```
heroku config set TUMBLR_REDIRECT_BASE_URL=http://example.com/blog/ ```
-
Push the app to Heroku:
```
git push heroku master ```
-
Add your Tumblr custom domain as a domain in Heroku:
```
heroku domains:add blog.example.com ```
-
Visit your Heroku app and make sure it is redirecting to the correct place
All paths in this format: /post/123456/**slug** will redirect to your TUMBLR_REDIRECT_BASE_URL with only the **slug** appended. All other paths are redirected to the TUMBLR_REDIRECT_BASE_URL itself. An easy way to check that redirection works correctly is to get a path to one of your blog posts on Tumblr, like /post/123456/slug, then: ```
curl -I -H 'Host: blog.example.com' http://your.herokuapp.com/post/123456/slug ```
and make sure you get a 302 FOUND response with the Location header leading to the right place on your new blog.
-
When the redirection is working correctly, set the app to do permanent redirects:
```
heroku config set TUMBLR_REDIRECT_CODE=301 ```
-
Point your Tumblr custom domain away from Tumblr and to the new Heroku app by updating the CNAME record to point to your.herokuapp.com instead of domains.tumblr.com
-
You're done! When the DNS change has propagated, any requests to your old Tumblr custom domain blog will now be redirected to your TUMBLR_REDIRECT_BASE_URL, without it costing you anything as long as you run the Heroku app with the single free dyno they provide.