How do I change the name of my WordPress site?

Option 1

You can change the name of the site (domain) using the WP-CLI console utility

This will also require ssh access to the server.

To change your WordPress domain name using WP-CLI (WordPress command line), you will need to follow a few steps. Please create backups before you start.

First, navigate to your site directory using the cd command (replacing domain.com with your domain):

cd domains/domain.com/public_html

Then run the command to determine the domain name

wp option get siteurl

You can now change the domain name using the search-replace command. Replace old_domain.com with your old domain and new_domain.com with your new domain:

wp search-replace ‘old_domain.com’ ‘new_domain.com’

If your site uses HTTPS, note that you must also enable HTTPS link replacement:

wp search-replace ‘https://old_domain.com’ ‘https://new_domain.com’

After running the search-replace command, update the site settings to display the new domain. In the WordPress admin panel, go to “Settings” > “General” and make sure the “WordPress Address (URL)” and “Site Address (URL)” field contains the new domain.
After changing your domain, also make sure that all links and resources on your site use the new domain. You may have to manually update some links if they are in the template files.

Option 2

Another option is to change the name of the website address using SQL queries in the phpMyAdmin interface. You can access it through the DirectAdmin hosting control panel. Don’t forget to back up your base beforehand.

In phpMyAdmin, select your site’s database and click on the “SQL” link

Below is a list of commands to execute by replacing the name of the old and new domain. Also pay attention to the protocol you have specified, http or https.

/* update all post links */update wp_postsset guid = REPLACE(guid, ‘http://www.oldsite.com’, ‘http://www.newsite.com’)where guid LIKE ‘%http://www.oldsite.com%’;
/* update all links in post content */update wp_postsSET post_content = REPLACE(post_content, ‘http://www.oldsite.com’, ‘http://www.newsite.com’)where post_content LIKE ‘%http://www.oldsite.com%’;
/* update all links in the meta */update wp_postmetaSET meta_value = REPLACE(meta_value, ‘http://www.oldsite.com’, ‘http://www.newsite.com’)where meta_value LIKE ‘%http://www.oldsite.com%’;
/* update options */update wp_optionsset option_value = REPLACE(option_value, ‘http://www.oldsite.com’, ‘http://www.newsite.com’)where option_value LIKE ‘%http://www.oldsite.com%’;
Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support