How to move a site to another domain CMS WordPress
If you need to change the domain of the site or you have already transferred your script to a new domain, and you use WordPress as a CMS, then there are several ways to change the domain:
- Changing the domain in the administrative part of the site
- Additional steps required after changing the primary domain
- Using SQL queries
Let’s start with the first option, that is, by changing the domain in the administrative part of the site
- First you need to log into the WordPress console (admin panel), usually it is available via the link wp-login.php or admin/, that is::
- After authorization, in the sidebar on the left, go to the Settings – “General” section
- On the page that opens, change the domain name in the lines::
– WordPress Address (URL)
– Site Address (URL)
- To save the changes, click on the Save Changes button
Additional steps required after changing the primary domain
Usually, this is the end of the domain change, but in rare cases, when working on the site, a direct link can be inserted in any of its parts, that is, a link that will contain the name of the site, for example, you directly indicated in article link to uploaded content:
Then, when changing the domain name, this link will not change and, as a result, this file will not be loaded, the site will not work or will not be displayed correctly.
For such cases, there are special plugins that are designed to search and change the domain in the entire database of your site, for example:
– Better Search Replace
– Search & Replace
Their interface is extremely simple, in one field you indicate what you need to find, in the other what you need to replace.
As an additional recommendation, if you are using caching plugins (WP Super Cache, W3 Total Cache), then after changing the domain of the site, please clear the cache in the settings of these plugins so that the cached information does not interfere with the correct operation of the site.
The second way in which we will consider changing the domain using SQL queries in phpMyAdmin
- Login to the hosting control panel and go to the file manager
- Find the wp-config.php file and open it for viewing, usually this file is located in the document root of the site
- Find the lines:
define ( 'DB_NAME', ‘database_name’ );
where database_name is the name of your database, remember the database name
$table_prefix = 'wp_';
where wp_ is the name of the table prefix in the database ‘database_name’
- Go to PHPMyAdmin and select the database in the left column you found in the previous step
- Then go to the “SQL” tab. Here you need to make four requests. They can all be executed at the same time, just insert each query on a new line.In order for the requests to work correctly, please replace the site address in them:
– instead of domain.com, specify your old domain, and instead of newdomain.com – new;
– also substitute the real table prefix for wp_ after the word UPDATE.
The first request is to change the site’s domain name in the WordPress settings:
UPDATE wp_options SET option_value = replace(option_value, 'domain.com', 'newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
The second request is needed to change the WordPress domain in the content of articles and pages:
UPDATE wp_posts SET post_content = REPLACE (post_content, 'domain.com', 'https://newdomain.com');
The third request is to change the WordPress URL in the comments:
UPDATE wp_comments SET comment_content = REPLACE (comment_content, 'domain.com', 'https://newdomain.com');
The fourth request is to change the WordPress domain name in the profile links of users who left comments:
UPDATE wp_comments SET comment_author_url = REPLACE (comment_author_url, 'domain.com', 'https://newdomain.com');
- This completes the domain change.
Checking the site for a new domain
After changing the domain, you need to test the site. To do this, clear your browser cache and then test your site on the new domain.