Transfer a WordPress site from one domain to another.

While moving a wordpress site from one domain to another, you might find out that the site just breaks down – the layout is broken, the pictures disappear or it is simply not loading at all. This instruction will help you if you need to:

  • transfer from one domain to another or from a subdomain to the primary domain;
  • migrate from the ../domain.com/wordpress subdirectory to the main directory ../domain.com/;
  • move website from one domain to another;

Move wordpress site from one domain to another

The transfer might consist of few steps, including SQL queries to change the settings in Phpmyadmin, files migration to a different folder and even a config file edit if you have a VPS. Lets review all three.

Update wordpress SQL tables in Phpmyadmin

All actions should be done in phpmyadmin. Phpmyadmin location depends on webserver setup, often it is available at domain.com/phpmyadmin or similar address, and requires authorization with login and password.

You need to correct the site address in the database in few tables. Select the required database and go to the SQL tab to enter those three lines:

UPDATE wp_options SET option_value = REPLACE(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = REPLACE(guid, 'http://olddomain.com','http://newdomain.com');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://olddomain.com', 'http://newdomain.com');

Where olddomain.com is the former domain of the site, and newdomain.com is the new domain of the site. If you are using an SSL certificate for the site, replace http with https.

Important: if you have a Cyrillic domain, the domain name in SQL queries must be entered in Punycode format. To convert the Cyrillic domain to Punycode format, use any online converter.

For example, you need to transfer the site to the Cyrillic domain:

новыйдомен.ru

The name of this domain in the Punycode format looks like this:

xn--b1aedoqcfcd1k.ru

In this case, you need to enter a SQL query with Punycode domain.

An error has occurred. If you see a similar error:

1146 - Table 'wp_options' does not exist

Check whether such a table exists wp_options.

The table prefix may differ from wp, for example: the table is called yourprefix_options, where yourprefix is any set of letters and numbers. If the prefix is ​​different, change the name of the tables in all three queries above.

Move files to a different folder

Hosting providers often bind every domain to a folder with a corresponding name. If this is your case, make sure to move files to a folder with a newdomain.com name. Copy-Paste methods may differ depending on the hosting control panel / your ability to use FTP/SFTP file managers.

Modify webserver Nginx / Apache configs

If you use a VPS / custom webserver you might avoid moving files from one folder to another if you simply set up a site config to look at the current folder for the new domain:

Nginx:

server {
listen 80;
server_name newdomain.com;
root /var/www/olddomain.com;
#Other config settings..
}

Apache:

<VirtualHost *:80>

DocumentRoot /var/www/olddomain.com/
ServerName newdomain.com
ServerAlias www.newdomain.com

<Directory "/var/www/olddomain.com/">
allow from all
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
</Directory>

</VirtualHost>

Clear all caches

Clear the wp-content/cache/ folder if you have caching configured. Also make sure to check the site with incognito mode and look through other caching methods you have enabled.

Follow Sam Tyurenkov:
Hi there, I'm a web-designer, marketing and product manager, business developer. I have created this website and about 25 others. I'm also doing various tasks for IT projects besides websites - like mobile games.