Question

So, I want to change my tumblr url and redirect everyone from my old one to the new one, but I want them to be redirected to the post they were linked to, for example /post/64948618646. I'm quite fond of this code:

<script type="text/javascript">
<!--
   window.location="http://someurl.tumblr.com";
//-->
</script>

so is it possible to somehow get this like http://oldurl.tumblr.com/post/64948618646 redirect not only to http://newurl.tumblr.com but also http://newurl.tumblr.com/post/64948618646?

Was it helpful?

Solution

you would probably get away with:

window.location.href = "http://new-url.com" + window.location.pathname;

OTHER TIPS

I am not too familiar with Tumbler, but I am going to assume the last number in the URL you provided is a GET value. If so, and you are using PHP, find the GET variable name and use the following:

$post_number = $_GET["variable_name"];

Then in JavaScript, grab the post number

var post_number = <?php echo $post_number; ?>;
var url = "http://someurl.tumblr.com/post/" + post_number;
window.location = url;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top