How To Change Your WordPress Website’s Domain Name
4 mins read

How To Change Your WordPress Website’s Domain Name

wordpress website domain

 WordPress Website Domain

wordpress website domain Changing your website’s domain name has advantages and disadvantages, but it’s a decision that should be considered carefully, especially if you have an established WordPress site.

Having said that, there are valid reasons for changing a domain name, and if the need arises, it’s crucial to handle the process correctly.

The good news is that changing the primary WordPress URL is quite simple. You’ll need to adjust some WordPress settings in two different places, but both tasks are straightforward.

In this post, we’ll guide you through changing your existing domain name within WordPress, with essential tips to ensure a successful transition. Let’s begin!

1. Backup Your Website

Before making any changes, it’s crucial to back up your website to avoid data loss.

  • Files: Use an FTP client or your hosting control panel to download all your website files.
  • Database: Export your database using phpMyAdmin or a backup plugin.

2. Update WordPress Address and Site Address

  1. Log in to your WordPress admin dashboard.
  2. Navigate to Settings > General.
  3. Update the WordPress Address (URL) and Site Address (URL) fields with your new domain name.
  4. Save the changes.

3. Update the wp-config.php File

To ensure your new domain is correctly referenced, you can define it in your wp-config.php file.

  1. Access your website files via FTP or your hosting control panel.
  2. Open the wp-config.php file.
  3. Add the following lines, replacing https://newdomain.com with your new domain:phpCopy codedefine('WP_HOME', 'https://newdomain.com'); define('WP_SITEURL', 'https://newdomain.com');
  4. Save and upload the updated file.

4. Update the Database

To replace all instances of the old domain with the new one, you’ll need to run a database search and replace.

  1. Using a Plugin:
    • Install and activate a plugin like Better Search Replace or WP Migrate DB.
    • Use the plugin to search for your old domain and replace it with the new domain.
  2. Using phpMyAdmin:
    • Access phpMyAdmin via your hosting control panel.
    • Select your WordPress database.
    • Run the following SQL query, replacing olddomain.com and newdomain.com with your respective domains:sqlCopy codeUPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET guid = replace(guid, 'http://olddomain.com','http://newdomain.com'); UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://olddomain.com','http://newdomain.com');

To ensure all links and images reference the new domain, you may need to update them manually or use a plugin.

  • Plugins: Use the Better Search Replace plugin to search and replace URLs in your content and metadata.

6. Redirect Old Domain to New Domain

Set up a 301 redirect from your old domain to your new domain to preserve SEO rankings and ensure visitors are directed to the new site.

  1. Access your .htaccess file via FTP or your hosting control panel.
  2. Add the following code, replacing olddomain.com and newdomain.com:apacheCopy codeRewriteEngine on RewriteCond %{HTTP_HOST} ^olddomain\.com [NC] RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301,NC]

7. Update Google Search Console and Analytics

  1. Google Search Console:
    • Add the new domain as a new property.
    • Use the Change of Address tool to notify Google of the domain change.
  2. Google Analytics:
    • Update the property settings to reflect the new domain.
    • If necessary, create a new property for the new domain.

Update your domain name on social media profiles, business listings, and any other platforms where your old domain was used.

9. Verify and Test

  1. Verify: Ensure that all links, images, and references to the old domain are updated.
  2. Test: Navigate through your site to ensure everything is working correctly and the new domain is fully operational.

By following these steps, you can successfully change your WordPress website’s domain name while minimizing downtime and maintaining SEO rankings.