Let’s assume you were using abc.com domain for your blog and later you decide to change it to xyz.com. Because of reasons like low traffic, not related to your niche, already purchased by someone but the extension is different, domain is blacklisted but after buying you came to know, etc.
So, you might get stuck how to replace the old domain name with the new domain name. Not to worry, if you are planning to use WordPress on a new domain then you need to follow a few steps for the smooth working of your new domain in WordPress. Those steps are mentioned below:
First Step: Using the WordPress Dashboard
Being a WordPress site owner, this step is easy for you to follow and implement. Go to setting > General and replace WordPress Address and Site Address with the new domain that you want to utilize for your WordPress website.
• The “Site Address (URL)” in the setting is the address that you want people to type or browse to land on your WordPress blog.
• The “Site Address (URL)” in the setting is the address that comprises of WordPress core files reside.
Second Step: Via FTP
You can also add the new domain in your WordPress site via FTP. This method is useful, if you have the right to access your website via FTP. Moreover, this will easily help you to get a website back up and run the same, if values are entered incorrectly in the dashboard.
Edit wp-config.php
You can also place the site URL manually in the wp-config.php file.
To follow the same insert these two lines to your wp-config.php, where “yourdomainname” is the right location of your WordPress site.
define('WP_HOME','http://yourdomainname.com');
define('WP_SITEURL','http://yourdomainname.com');
This may not be the best fix because it’s a hardcoding of the values into the website source code and you can’t do the same in the general settings page.
Edit functions.php
1. You need to download a copy of the active theme’s function.php file. Edit that downloaded a copy in a simple text editor and upload that edited copy again on the website.
2. Insert these two lines to the file, next after the initial “<?php” line.
update_option( 'siteurl', 'http://yourdomainname.com' );
update_option( 'home', 'http://yourdomainname.com' );
3. Upload the edited file again on the website without changing the location.
4. Refresh the login or admin page multiple times, to get the same site again with the backup.
Note:
i) Don’t leave those lines in the function.php file. Remove the lines once the site is live.
ii) In case, your theme is not supporting a function.php file then you can create a new file known as function.php in a text editor and implement the above-mentioned steps.
Third Step: Using phpMyAdmin
You are required to change the website URL and home options in your WordPress database. You can do this into the cPanel > phpMyAdmin.
In phpMyAdmin, choose your WordPress database and browse the table wp_options. Search the alternatives siteurl and home and replace their values to the new domain that you want to display publicly.
Last but not least don’t forgot to clear the cache of your browser and check whether your website is working or not.