Skip to content

How to manually move WordPress website to another host, address of folder?

This How to is more than 2 years old and may be outdated.

Report an error in the How to

It's very usual that you have to move WordPress website from one address to another one. For example, this is useful if you're switching from localhost to production domain, moving website to a subdomain or just adding https instead of http. In this tutorial, we're going to cover the whole process without any plugin.

How to manually move WordPress website to another host, address of folder?

This process was constantly tested since version 2.9 to new versions 5.2.x.

Imagine that you have WP locally on your computer e.g. http://localhost/my-site and you have to transfer it to production domain e.g. https://www.my-site.com.

Important: Before any work, make sure that you have backups that can be restored successfully.

Step 1

Login to admin locally

Open Administration (e.g. http://localhost/my-site/wp-admin) with your credentials and then go to Settings > General.

Change the following to new values:

  • WordPress address (URI)
  • Blog address (URI)

The new value should be something like https://www.my-site.com (without trailing slash!)

Click “Save Settings” to confirm new values. After you changed these values, don’t try to access the website locally.

Step 2

Copy all files to new location

Copy all folders and files to new location (wp-admin, wp-content, wp-includes + files in website’s folder).

Tip: if you have cPanel or SSH access, you can compress all files into a zip archive. Transfering single file and extracting afterward is a much faster way than transferring files one by one.

Step 3

Database

Make database export using the “Export” option in phpMyAdmin on your machine.

After that, create an empty database, assign user to it and start import of .sql(.gz) file on new location. This can be achieved using phpMyAdmin as well or you can use terminal (mysql -u username -p database_name < mysite.sql).

Step 4

Adjust wp-config.php

This file is usually located in the root folder of your website and it contains all the information to connect to DB.

Change the following lines:

define('DB_NAME', '...');
define('DB_USER', '...');
define('DB_PASSWORD', '...');

Your website should be accessible on new address now.

Step 5

Update permalinks

Open administration on new location (e.g. https://www.my-site.com/wp-admin) and go to Settings > Permalinks

Press “Save Changes” to update the permalinks structure.

Step 6

Replace all occurrences of old addres in DB

Execute query 1:

UPDATE wp_posts SET guid = REPLACE (
guid,
'http://localhost/my-site',
'https://www.my-site.com');

Execute query 2 to update all references in post content.

UPDATE wp_posts SET post_content = REPLACE (
post_content,
'http://localhost/my-site',
'https://www.my-site.com');

Keep in mind that you have to change these example values with real ones. There is also a possibility that your DB uses prefixes different than “wp_”

Step 7

Additional checks

Go through all files and check if there is any reference to an old address. If you have ssh access you can run “grep -r 'http://localhost/my-site' .”

Using the “Search” option in phpMyAdmin, you can perform search in rest of the database with the following criteria:

  • Words or values to search for (wildcard: “%”): %http://localhost/my-site%
  • Find: the exact phrase as substring
  • Inside tables: all tables

Some plugins and themes store data in DB other tables like wp_postmeta and wp_options and in such cases, data is serialized. The serialized data format is specific and it can’t be changed as regular text. For example, if you have a:1:{s:3:”url”;s:24:”http://localhost/my-site”;} you can count characters and update it as well a:1:{s:3:”url”;s:23:”https://www.my-site.com”;}.

There are some plugins like Duplicator which may help with WordPress migration, especially with serialized data, but in some cases, they don’t work in an expected way and that’s why we prefer manual migrations.

If you use a lot of plugins, check if everything works fine. For example “Google XML Sitemaps” requires sitemap.xml regeneration.

In the end, make sure that Google and other crawlers can access your website.

If you have any questions, you can always ask Daisy for help

Comments 1

Be the first to comment