Redirect WordPress Posts from an Old Domain

Posted on Posted in Development, Extras, Information, Tech, Tips

Simple Code

Recently I had a problem when I moved my blog from to I had far too many links on other sites that still looked like, and wouldn’t redirect to the new blog’s location. I wouldn’t even know where to start if I had to change all of those.

Instead, I threw together a simple redirection script that I thought I’d just share in case anyone needed it. It’s nothing fancy at all, and stupid easy to set up. There are many ways of doing this, and in my opinion, this is the easiest.

This is explained in a way that even common folk who just want to move their blog will understand. Sorry if I insult your intelligence.

1. Create a file called index.php

Pop open notepad, go to File > Save As…, set the filename as index.php, and then go directly below that and make sure to set Save As Type to All Files.

2. Copy the script into the text editor

	$post = $_GET["p"];
	$new = "";
	$string = $new . "?p=" . $post;

	echo "Redirecting to " . $string;
	header("Location: $string");

3. Plug in your information

This is easy. Just plug in your blog’s new address where is. Make sure to include the http://. If your blog was located in another directory, you’re also able to include it like so: Otherwise, omit anything after the domain name.

4. Presto, now save it and upload it to your server

Do a quick CTRL+S to save and upload it via FTP to the root of where your old blog used to reside.

Now you’re done. That was easy!

Leave a Reply

Your email address will not be published. Required fields are marked *