Changing the CMS WordPress Domain

If you decide to change your website’s address, you also need to change a number of settings in WordPress itself besides the changes in the domain in the hosting settings. 

This step-by-step instruction describes actions you need to take to change the name of the website inside  WordPress CMS.

Before you begin, remember to make a copy of your database just in case!

Let’s look at 2 variants:


The number of characters in the new domain coincides with the previous domain

  1. Go to phpMyAdmin and choose the database of your site. 
  2. Press the SQL tab and complete the next query changing the old domain name to the new one. Pay attention though. At the end of the address, there should be no slash (/), and there should be HTTP protocol and not the HTTPS one:

UPDATE wp_options SET option_value = REPLACE(option_value, '', '') WHERE option_name = 'home' OR option_name = 'siteurl';

3. Go to the admin panel of your website to the Settings - Common.

4. In the WordPress Address and Blog Address fields, indicate the URL for the new domain and confirm the changes pressing the Refresh Options button.

5. If there is no possibility to do steps 3-4, then do the following queries, in turn, changing to the new website address. Pay attention that there is no slash (/) at the end of the address:

UPDATE wp_posts SET guid = REPLACE(guid, '', '');

UPDATE wp_posts SET post_content = REPLACE(post_content, '', '');


The number of characters is different

We’ll need the WP-CLI package. The package will require the PHP 5.3.2+  version

  1. Installing WP-CLI on Linux and OS X

$ curl -L > wp-cli.phar

The given command will load the wp-cli.phar file. To check the compatibility with the package, start the WP-CLI package with the --info parameter:

$ php wp-cli.phar --info

PHP binary: /usr/bin/php

PHP version: 5.4.24

php.ini used:

WP-CLI root dir: phar://wp-cli.phar

WP-CLI global config:

WP-CLI project config:

WP-CLI version: 0.14.1

suhosin must be turned off!

If the system is compatible, you can go ahead and copy the wp-cli.phar file into any directory which is located in the $PATH system variable. The copying is done so that WP-CLI can be called from any directory. The wp-cli.phar file itself must also be marked as executable. 

$ chmod +x wp-cli.phar

For the VPS server, if you’ve logged under the root user:

$ mv wp-cli.phar /usr/bin/wp

For the shared/common Linux hosting:

$ mv wp-cli.phar /home/user/wp

$ vim ~/.bashrc

we add alias wp="/home/user/wp"

And log again via SSH.

After that, you can run wp --version from any directory.

  2. Changing the domain name

Go to the root catalog of the website

cd /home/user/public_html/

We’ll ‘ask’ WP-CLI to change the to with the help of search-replace command

wp search-replace '' ''

We see the following result:

Success: Made 238 replacements.


Was this answer helpful? 0 Users Found This Useful (0 Votes)