CityHost.UA
Help and support

How to change the name of a WordPress site?

Due to the specifics of the WordPress CMS, it uses a global link to the website URL (domain). These parameters are globally specified in the CMS itself and are called using the WP_HOME and WP_SITEURL parameters.

Additionally, the site's database stores hundreds to thousands of domain mentions in the form of links to files, images, pages, news, menu sections, etc., so the process of renaming the site takes place with the help of automated tools. Auto-replacement does not always happen perfectly due to the peculiarities of the created site, so you should be prepared for the possibility of manually correcting non-working links in the site code.

A simple renaming option using WP-CLI

1 Activate the WP-CLI console utility ? [instructions]

2 Enter the WEB-SSH console ? [instructions]

3 Go to the directory of the WordPress site for which you want to change the password using the cd command together with the path to the site, as an example:

 cd www/vash-site.com.ua

4 Let's get information about the domain and the protocol currently used on the site:

 wp option get siteurl

5 Run the command to find and automatically replace mentions of the old domain with the new one. Please note that 2 domains are specified in the command, the old one on the left and the new one on the right. It is also worth emphasizing the protocol with which the old domain is specified - http or https (we will learn this in point 4) and perform auto-replacement while preserving the correct protocol.

 wp search-replace "https://vash-site.com.ua" "https://new-domain.net"

6 If everything is done correctly, the result of the execution of the last command will be the green text Success and the number of places in which autoreplacement was performed.

7 In the last step, rename the site on the hosting ? [instructions]

An advanced version of renaming through the database

1. Connect to the database used on your site.
You can find out the database used on the site using [instructions] , and enter the PhpMyaAdmin database management system using [instructions]

2. Next, on the left in the menu, select the required database [1] by clicking on it with the right mouse button and go to the menu [SQL][2]:

3. In the new window, insert the following sql-queries and press the [NEXT] button:

 UPDATE `wp_options` SET `option_value` = 'http://ІМ'Я-НОВОГО-ДОМЕНУ' WHERE `option_name` IN ('siteurl', 'home');

— instead of the prefix wp_, the prefix of the tables of your database should be specified. The default is wp_;
— instead of http://NEW-DOMAIN-NAME, the new address of your site should be specified, taking into account the protocol: http or https, taking into account www or without www for the correct operation of the site;


The recommendations below are optional. Before executing them, we recommend that you first download a backup copy of your database.


There is a method of global replacement of old domain URL data with a new one in site publications (articles, links to pictures and various objects). To replace links, use the following sql query construction:

 UPDATE `wp_posts` SET `guid` = REPLACE(guid, 'СТАРИЙ-ДОМЕН','НОВИЙ-ДОМЕН'); UPDATE `wp_posts` SET `post_content` = REPLACE(post_content, 'СТАРИЙ-ДОМЕН', 'НОВИЙ-ДОМЕН');

— instead of OLD-DOMAIN / NEW-DOMAIN, specify the corresponding values, if necessary from http/https/www, depending on how the old domain was specified.
— if your theme / module or plugin uses serialized data for storage, then the above method of replacing the URL in the wp_posts table will only harm, since after the replacement, the serialized array will not be decoded due to the mismatch in the number of characters;




Similar articles