How to Change your WordPress Domain Name and Host

Changing your WordPress domain name and host can be a difficult and time consuming process. I wanted to write this article to help others do it, and serve as an easy way for me to remember how to do it. With so many steps and possible errors it’s easy to forget how to do it correctly. This can also serve as a great way for you to make a live duplicate test site, so you can test changes to your existing site before actually making them live.

Computer with countdown to change on screen

Photo courtesy of the Irish Labour Party

Please backup everything including your database before you do this.

Steps to change your WordPress domain name and host:

The first step changing your domain name

  1. Login to the WordPress admin panel on the old name and host. Go into Settings.
  2. Under WordPress Address (URL) & Site Address (URL) change into the new domain name including the file extension if you want it to be installed in a subdomain or subfolder of another site. For example: http://my-domain.com/my-subdomain-installation
  3. Change both and don’t use a trailing slash, usually you will want them to be the same, make sure its correct, then and only then click save.
  4. Now your site will not be reachable. Don’t panic.

Download the old WordPress Database

  1. Login to your existing old host and download the database for your site.   To do this find the location of your databases with your old host, usually located somewhere on the backend of your old host. and their should be a phpMyAdmin login.
  2. Find the name and password of your server to be able to access the database in phpMyAdmin. It should be easy to find the login and you can easily reset password to get in.
  3. Take note of the name of your database, select it, and click on export.
  4. Save the file (the name isn’t too important here)

Download your old sites wordpress files

  1. Create a new folder on your desktop or somewhere easily accessible.
  2. Then using ftp log into your old site host and download the entire folder containing all of your site data (this is the same folder that contains wp-config, wp-admin- wp-content) into the new folder on your desktop.
  3. This will take a while so while you are waiting for the download go onto the next step.

Creating a new database and updating your old MySQL database

  1. Login to your new website host.
  2. Find the database section and create a new database. (You can use a new name or an old one.)
  3. Write down the database name, and password.

Prepare your old MySQL database before importing to new database

  1. Now use this search and replace domain tool or a similar tool with your old database you just downloaded. Use a tool for this part don’t do it by hand as things can get broken easily.
  2. In the replace query insert your old domain name. Be real careful here and make sure you have it correct before you hit process. If your main domain uses the www. make sure to include it, and don’t use a trailing /.
  3. Save the new processed SQL database and open it with a text editor. Your going to want use a text editor like notepad++.
  4. Search for your old database name and replace it with your new one that you created above. It should only appear 1-3 times near the top. If you see a line for “CREATE” followed by your database name you might need to delete this. But be careful. First try to upload if you have trouble you can always delete it. Since your database is already created you should be ready to upload.
  5. Go back to your new host and the database you created. Log back into the new database you created using phpMyAdmin and import the edited SQL database. Hopefully it uploaded without any errors but if you did get an error at this point it probably is in those first few lines that you changed in your SQL database. Double check that your database name is correct.

Import the old WordPress files into your new host and directory

  1. Now back to ftp now that your wordpress files have finished downloading disconnect and connect with ftp to your new server.
  2. Create a file in your main directory for the site. The location of your site on the host needs to match the URL you entered in your WordPress settings when you saved it last.  For example if you chose http://my-domain.com/my-subdomain-installation , then you will want to create a folder named my-subdomain-installation on the new server within the folder my-domain.
  3. Upload your files into the new directory.

Edit the config.php file to connect the wordpress files with the new database

  1. Once the upload is finished use ftp to login to your new host server
  2. Open up your config.php file in your main WordPress folder of the new installation.
  3. Edit the file and enter in the database name, server name, and password you created earlier for the new database. Note: some hosts the database name and the server name are the same thing. Be very careful don’t add any spaces or characters.
  4. Save the edited config.php file and ftp and save back to the new wordpress folder.

Your almost finished with the transfer and domain change

  1. Now you should be able to login to your new admin panel on the new domain name http://my_domain.com/my_subdomain_installation/wp-admin.
  2. Go into settings and click on permalinks.
  3. Select the same settings you had on the old site or your internal site linking will be broken.

What about the old installation?

Now your new site should be up and running but what about your old installation.

  1. If you want to fix it so you can log back in:using ftp log into your old servers main wordpress folder > wp-content > themes > your old active theme>functions.php.
  2. Using FTP add this line of code to your functions.php.

Now you should be able to log back into your wordpress admin panel. Delete the code you just placed in your functions.php.

Congratulations, lets celebrate by backing it all up!

That’s it! You did it! If you have any problems with your database connecting to your site the error is usually found in your config.php file. Make sure to create a backup of your new database right away. Most hosts have this option but few automate it.

If this sounds all way too complicated and you want a tool to that will make this a lot easier check out Backup Buddy.

Have you done this before? Tell me about it.

About John Schuster

My passion is helping business owners and entrepreneurs use the internet to find customers and make money. This includes email marketing, social media marketing, content marketing, PPC, and SEO. I work hard to be the best, and with that bring an arsenal of tools to help you business. Call me (206) 235-4131 Please feel free to use me as a resource and contact me with questions.
This entry was posted in Web Development. Bookmark the permalink.

Leave a reply