In this area there are alot of tutorials and howto’s but here is a small step by step on how i did it.

  1. Copy all the files from the old blog to your new folder.
  2. Open your database with a manager like phpMyAdmin or in a console. You need to edit the table wp-options and change the values for two variables “home” and “siteurl”. In there you will see there is the old address of your site. Just change them to reflect the new ones. If you want to change a DB server then you can get a dump from the database and edit the values in a simple notepad editor.
  3. Optionaly, make sure that if you change a db server, wp_config.php is reflecting the new values.
  4. You should be set up by now. WordPress will take care of the rest. When i say the rest i mean two big things. Internal links, which will be updated automaticaly and the .htaccess file which will also be recreated by the platform (i love wp did i tell you that? 🙂 ).


Now, you don’t want to loose your traffic from your old URL. The traffic comes to your blog mainly with either of the following ways. It is either direct traffic (i.e. somebody types your blog address on their browser) or from search engines. For both types of visitors you need to provide a way not to loose them. What i did is this. I created a .htaccess file redirecting all traffic to an index.php file (the .htaccess that wordpress had will do just fine) and from that file sending the traffic to the new site informing the visitors of the change. Here are the two files:

.htaccess file:

# BEGIN WordPress

RewriteEngine On
RewriteBase /myblog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /myblog/index.php [L]

# END WordPress

index.php file:

<?php
header ('HTTP/1.1 301 Moved Permanently');
$request = substr($_SERVER['REQUEST_URI'], SUBSTRING_LENGTH, strlen($_SERVER['REQUEST_URI']) - SUBSTRING_LENGTH);
$location = 'http://www.newblog.com/'.$request;
header('Location: '.$location);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<html>
<head>
	<title>MyBlog -> stratos.me</title>
	<meta http-equiv="refresh" content="5;URL=http://www.newblog.com/<?php echo $request; ?>">
</head>
<body>
We have moved! Now the new blog section is called
<h1><a href="http://www.newblog.com">www.newblog.com</a></h1>
You should be redirected there shortly. Please update your bookmarks!
</body>
</html>

This way, the human visitors will see a message telling them about the move and the search engine robots will get the first header we send them. There we actually tell them that the page has moved permanently so they will know and update their search indexes. Moreover, if someone finds an old link on a search engine, he will be redirected to the same location on the new blog url.

Let’s see this by an example. Let’s say someone finds my gallery link on a search engine. It will be something like http://stratosector.net/myblog/gallery. The new link that will come out of the above script will be http://www.newblog.com/gallery. I need to point out one thing. The SUBSTRING_LENGTH variable is actually the string length of the subfolder of your old blog. For instance, for my old url http://stratosector.net/myblog/ the string length would be 8 (/myblog/).

I hope this helps you guys out with your migration as it did for me. Ah, i almost forgot. Backup your blog files and your database so in case something goes extremely wrong you can rollback!