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.
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
- Login to the WordPress admin panel on the old name and host. Go into Settings.
- 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
- 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.
- Now your site will not be reachable. Don’t panic.
Download the old WordPress Database
- 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.
- 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.
- Take note of the name of your database, select it, and click on export.
- Save the file (the name isn’t too important here)
Download your old sites wordpress files
- Create a new folder on your desktop or somewhere easily accessible.
- 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.
- 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
- Login to your new website host.
- Find the database section and create a new database. (You can use a new name or an old one.)
- Write down the database name, and password.
Prepare your old MySQL database before importing to new database
- 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.
- 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 /.
- Save the new processed SQL database and open it with a text editor. Your going to want use a text editor like notepad++.
- 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.
- 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
- Now back to ftp now that your wordpress files have finished downloading disconnect and connect with ftp to your new server.
- 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.
- Upload your files into the new directory.
Edit the config.php file to connect the wordpress files with the new database
- Once the upload is finished use ftp to login to your new host server
- Open up your config.php file in your main WordPress folder of the new installation.
- 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.
- 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
- 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.
- Go into settings and click on permalinks.
- 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.
- 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.
- 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.