Redirect Tumblr to a New domain

Tumblr we have moved

So, you need to redirect your tumblr to a new domain or website? Migrating can be a PITA. I did it for STOPSTEALINGPHOTOS.COM when they wanted to move to WordPress.  After doing some research I knew it could be done, but I could not find any examples on how to redirect to the new domain correctly and it goes to the right links and everyone, including Google links to the old domain.

Tumblr blog, minus the "slug" number system. I made a Regex Pattern that removes the domain and slug numbers and spits out the title. That's all. If you are using wordpress and need the convert from Tumblr then try Tumblr2WordPress: Export Your Tumblr to WordPress.

All I had to do was replace the the code here and overwrite the theme (removing the old theme) and disable the mobile theme and bam .... it works

<!--This needs to be inside the <head>-->
<head>
<meta name="description" content="this blog page has moved you will be redirected to my new blog">
<script type='text/javascript'>
var end_anchor = window.location.href; //This is a fix for Disqus #comment anchors
var new_slug = window.location.pathname; //Path from the tumblr domain "domain.tumblr.com/post/POSTID/POSTTITLE
   var new_root = "http://your-new-url.com"; //Your New Domain
   var new_url = new_root + new_slug; // The New root Domain and the tumblr Slug
   document.write("<link rel=\"canonical\" href=\"" + new_url + "\">");
</script>

<!--This needs to be inside the <body>-->
 <script type='text/javascript'>
var rdurl = new_url;
  rdurl = rdurl.replace(/\s*[a-zA-Z\/\/:\.]*domain.com\/post\/([0-9]*)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*.*)/, '$2'); //Regex Pattern removes /post/postid

//Lets search for an end anchor
if (end_anchor.search('#') > 1)
{
end_anchor = end_anchor.replace(/https?:\/\/*.*.(#[a-zA-Z0-9_-]*)/i, '$1');
} else {
var end_anchor = '';
}

//alert('end_anchor: '+end_anchor);
//alert('new_slug: '+new_slug); //Debug popups for testing
//alert('new_url: '+new_url);
//alert('rdurl: '+rdurl);

if ( new_slug == '/' ) // if the slug is the tumblr root then it will have "/", if not then it will be the root domain and posttitle
{
window.location = new_root + end_anchor;
} else {
   window.location = new_root + rdurl + end_anchor;
}
</script>

Regex Anchor
Regex Tumblr Slug