Skip to main content

Moving a WordPress website

By Sue Johnson

If you create a WordPress website, it is good practice to first create a development site on your own computer then move it to your webhosting when it is finished.

You can’t just upload the website and database, it won’t work because WordPress uses absolute URLs and these will all need changing.

You may also want to move your website to a different domain name, or change it from http to https.

You can use plugins to do this. However, editing the URLs in the database is straightforward and this is the method which we will be looking at in this tutorial.

You will need to upload the files for your WordPress site to your webhosting using FTP or you can use an installer such as Softaculous to install WordPress.

Installing WordPress manually

To create a new database and user, the steps are as follows:

  1. Open phpMyAdmin from your control panel
  2. Create a new database
  3. Click on the ‘privileges’ tab then click ‘add user’
  4. Change the host to local
  5. Create a password for the user
  6. Check ‘Grant all privileges on database “yourdatabasename”.’

You will now need to export the database data from your old website. and import it to the new one.

  1. Select the database and click export
  2. Select ‘Custom – display all possible options’
  3. Select ‘Save output to a file’
  4. Find ‘Compression’ and select ‘gzipped’
  5. Scroll to the bottom and click go
  6. Now you can import the data to your new database
  7. Select the database and click import
  8. Click where it says ‘browse’ and select the database file you created

It will take a while to import the data especially on slower web hosts

Create a copy of the wp-config.php file and edit it as follows:

  1. Find where it says ‘database_name_here’ and change it to your database name
  2. Find where it says ‘username_here’ and change it to your user name
  3. Find where it says ‘password_here’ and change it to your password

You can normally leave the host name as localhost, but see instructions from your webhost if the database is on a different server

Find where it says ‘$table_prefix = ‘wp_’;’ and change wp_ to the table prefix you used for the development website. For good security it should be something other than the default wp_.

Now you can use FTP to upload the WordPress files. You need to see instructions from your webhost to find out where this is. You need to upload your edited wp-config file.

Using an installer

If you have used an installer to install WordPress on your webhosting, proceed as follows

  1. Upload the wp-content directory from your old site
  2. Import the database data you exported from your old website, follow the instructions above
  3. Edit the wp-config.php files to the prefix you used for your old website
  4. Delete the tables with the prefix the installer created

Change the URLs

At this stage, all the files and database you need will be installed. But your website will not be working.

  1. Go into phpMyAdmin, select your database and select SQL
  2. You will now be able to run queries on the database in the field which appears

Here are the queries you need. The examples use https and assume you have an SSL certificate installed. Use http if you don’t.

Change the site URL

UPDATE wp_options SET option_value = '' WHERE option_name IN ('siteurl', 'home')

You will need to change ‘wp_’ in ‘wp_options’ to the table prefix you used for your old website and change ‘’ to your new website domain name.

Change the URLs in the posts

UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://localhost/oldwebsite', '')

You will need to change the website URLs to whatever you used for your development site.

Change the URLs in the post meta data

This will only apply to some websites, for example if you used the Advanced Custom Fields plugin.

UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://localhost/oldwebsite', '')

If you have used URLs in your widgets, you will need to log into your WordPress website and change them manually.

Check the home page of your website, it should now be working.

Now check that the other pages are working. If you get an error, log in to your WordPress website and switch the permalinks off and on again.

Changing from http to https

You will only need to do the database queries to change http to https.