Tips To Move WordPress to New Server Using Same Domain

I always wanted to post a tutorial to move WordPress to new server same domain a long time ago, but for some reasons I haven’t done it.

So in this tutorial, we are going to move WordPress to new server using same domain. I am using wpdemoblog.com which is currently hosted in HostGator (for the demo purpose only) to BlueHost. Obviously, you can replace wpdemoblog.com with your domain name.

This tutorial can be used too from BlueHost to HostGator, or any hosts, I just use them for the demo.

So say, you have a blog now in HostGator, with the name wpdemoblog.com, and you want to move it to BlueHost.

What you want to do first, either move the domain from HostGator to a domain registrant like Namecheap, or bring the domain to BlueHost (as the new host). (While sign up the hosting plan, you need to specify, you already have the domain, and type wpdemoblog.com in your domain box.)

I would personally register the domain in namecheap.com, because it is easier to collect all of my domains, if you have or want to have more than one websites.

The point here is, do not delete the old website first, and do not change the dns server to point to your new server first, before your website is setup and running exactly the same like in your old server.

I know it’s a bit tricky to do this, but it’s the safest way, if you care about the down time of your website.

So let’s get started. I am using cPanel, you can use FTP client if you want to, I just use cPanel because it’s fast.

How I Usually Move WordPress to New Server Using Same Domain

1. You need to follow my other tutorial how to manually backup your entire website in this page first.

Without this, we can’t continue.

Say, the blog files are compressed under blogbackup.zip (example name) files, and the database is called dbbackup.sql (example file name)

Website files and database files
Website files and database files

2. So once you have the site backup, the .zip files and the .sql database, you can go to your new webserver’s cPanel, and go to File Manager.

3. Upload the blogbackup.zip file here, then extract the files in the same path.

Uploaded websites files - not yet extracted.
Uploaded websites files – not yet extracted.

Delete the blogbackup.zip from your cPanel.

4. Now, in cPanel Home, go to “MySQL databases” to create a new database, a new database user, and a database user’s password.

Add the user to the database.

Create a new database
Create a new database
Create a new user database
Create a new user database
Add user to database
Add user to database

5. Now, go to phpMyAdmin, and import dbbackup.sql the database you downloaded from step 1.

[pdtad]

6. In your site’s directory, edit wp-config.php and replace the old database data to the new ones we created on step (4) above.

Updating wp-config.php
Updating wp-config.php

Also, I recommend changing the secret key by going to this URL : https://api.wordpress.org/secret-key/1.1/salt/ and refresh your browser several times to generate the keys.

Replace the old secret keys in wp-config.php with this new one, and click “Save Changes” button.

WordPress Secret keys
WordPress Secret keys

7. Now, we want to see how our site looks like in the new server, so we need to view it locally in our computer using the shared IP address of the new server, while the old website is still running in the internet.

You can find the Shared IP address inside your cPanel home left sidebar.

Copy this shared IP address.

Shared Hosting IP address
Shared Hosting IP address – BlueHost

8. Modify our hosts file, if you use Windows 8.1 you can see this tutorial. On Mac, follow these steps.

Add the shared ip address on your cPanel and your domain, like in this screenshot.

This code on hosts file, will let us view our site only in our computer.

Hosts file - already modified
Hosts file – already modified

9. Now, open your site in your browser, it should show the website in the new server.

Note: at the same time, your old site is still alive in older server, because we haven’t changed the DNS to the new ones. You’re able to see this website in the server, because we just modified our hosts file in previous step above.

In the video, I edited the footer by adding the new server’s name just to make it easier for me, which site is with the new server, and which one is with old server.

10. Update the DNS server for your domain when the new server website is all setup.

11. Repeat the step 8, we want to delete the two lines we added before, to view our browser without new server’s IP.

12. If you see still, the old server website, this means, the domain isn’t propagated yet, it can take a few minutes to a few hours. But because we still have old website in the old server, and also in the new server, your website won’t have downtime.

Once you are sure that the website is already running in the new server, you can delete the old website. (make sure you have the backup first.)

4 thoughts on “Tips To Move WordPress to New Server Using Same Domain”

  1. Hi Kimmime,

    Thanks for sharing this! I am thinking about chainging hostings but keeping the same domain so this is really helpful to me. Again, thanks.

    I have one doubt: In my current hosting (I am with hostgator) I have my main domain (www.maymaindomain.com) and another addon domain,. As far as I understand, a addon domain works in fact as as subdomain of the main domain (Plese correct me if I am wrong)

    Then my doubt is: if I change hostings for my main domain following your procedure, what would happen with my addon domain in the old hosting? would it still be up for users, bearing in mind that it is an addon domain of my main domain and that this has already been moved to the new hosting?

    In fact, what I want is to move both domains , my main domain and may addon domain to the new host. What is in your opinion the best way to approach that?

    Very best regards,

    Jose

Comments are closed.