Send Ad Free SMS in India

An interesting problem to solve when migrating wordpress blog to a new URL

October 8, 2009 | In: How-To, Web 2.0

Problem Scenario
I migrated my blog from makuchaku.info to makuchaku.in – and wanted everyone who was linking to my “.info” domain, automagically gets linked to my “.in” domain. Ofcourse, I cannot change all the possible places from where my .info blog is linked.

Challenges

  1. I want “.in/” to be served when “.info/” is cliked
  2. I want “.in/blog/this-is-a-post” to be served when “.info/blog/this-is-a-post” is clicked.

Ofcourse, Challenge 1 is very east and straight forward. Just put up a redirection at .info domain and you’r done. Challenge 2 is interesting.

Solution
Goto your theme editor (old wordpress blog) and edit the template for which you want to setup redirection. For me, it was all posts and all pages. Next, insert this javascript code at the top of template code…

  1. <script type="text/javascript">
  2. // Redirecting makuchaku.info to makuchaku.in
  3. document.location = document.location.href.replace(/makuchaku\.info/, "makuchaku.in");
  4. </script>

Thats it. Now whenever you’ll hit http://makuchaku.info/blog/why-makuchaku – you will be redirected to http://makuchaku.in/blog/why-makuchaku – sweet!

Assumptions
This solution assumes that your new blog is a mirror replica of your old blog.

Please Digg this post if it helped. Thanks.

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Reddit Post to StumbleUpon

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Comment Form

blog comments powered by Disqus