4.2.2 Migration of WordPress site on new domain

Banner WP New Domain

Preparation for Migration

Before proceeding with the migration, you need to do two things:

  • copy all files from the directory of your old domain to the directory of the new domain;
  • ensure to create a backup of the website’s database, allowing you the ability to revert it to its previous state if needed.

Assuming all actions have been successfully executed. Now, all the files from the previous domain are present in your new domain’s directory. Making the site function correctly under the new address can be done in two ways.

Using WordPress Admin Panel

This is the simplest method, requiring minimal effort from your side.

1. Log into the admin panel of your website and navigate to Settings — General.

2. In the WordPress Address (URL) and Site Address (URL) fields, input the URL of the new domain and confirm the changes by clicking Save Changes.

Смена домена Wordpress

3. Done. WordPress will instantly redirect you to the login page of the admin interface, but now under the new domain.

Using phpMyAdmin

1. Access phpMyAdmin and select the database of your site.

2. Click on the SQL tab and sequentially execute the following three queries, replacing http://domain.com and http://newdomain.com in the examples with the old and new addresses of your site (note that there should be no trailing “/” at the end of the addresses):

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

3. Done. Now the site will open under the new address.