How I switched my Weblog to a new Domain Name

After the first step where I upgraded to the newest WordPress version (2.1.1), the second step was to do the real switch of the domain. And even this second step could be done in only about an hour.

I registered the new domain www.colblindor.com with the same provider as my old subdomain of my personal website. This made the switch a bit easier.

First I thought I have to map the new domain name to exactly the same folder as the old domain. But this idea was wrong. Because then crawlers like googlebot would just see duplicated content and I couldn’t tell them that I did the move, because I really didn’t do anything. Therefore the whole content had to be moved also.

At the same time I wanted to build a new database because I didn’t want to have two installations working on one database. If something wouldn’t work out, this could get bad. And through this I even could remove some extra tables from plugins which I don’t use anymore.

My first try to accomplish this looked like the following:

  1. Copying folder structure. First of all I had to copy the whole folder structure including all images. In my case this meant FTP download and FTP upload of all files.
  2. Config new database. I created a new empty database and configured it in wp-config.php.
  3. Export old database. The whole working database including all articles, comments, categories and more had to be exported as an SQL file.
  4. Import new database. Through the import you get everything in place for the new installation.

Finished with those four steps I tested if everything is running as expected. But unfortunately it didn’t, because the URL of the domain is hardcoded when embedding a picture and also hardcoded in some database tables. Therefore I had to alter the SQL file before importing it a second time.

To alter the file I found this neat little freeware tool called SCR. You can download it and do a replace in multiple big files. This comes in handy because opening a xMB file usually gives you some problems with normal text editors. So I replaced the old domain name through the new one in the whole SQL file.

Now the last two steps looked like this:

  1. Import database. For the second time but now with the correct domain values.
  2. Redirect URL. The last and most important step is to redirect the old domain to the new one. You have to do this inside the .htaccess file with a simple line:
    • Redirect 301 / http://www.newdomain.com/

    This works if and only if your old file structure looks exactly the same as the new one. The redirect sends each incoming request to the new domain.

Now everything worked as expected and it was done in only about an hour. My new domain is up and running and the old one redirects every request as it should.


One Response to “How I switched my Weblog to a new Domain Name”

  1. Domain Superstar Says:

    Good tutorial on moving to a new domain name. You may also want to mention that if you are changing around some file names (or changing from say html files to php files) that you can also easily do 301 redirects for each individual file in the .htaccess as well. Good stuff.

Leave a Comment