When changing the domain name of a WordPress powered website, WordPress settings should be modified to reflect the new name. The changes will allow WordPress to actually use the new domain. The links, images and attachments which refer to the old domain name should also be updated. Remember, that the domain name change means changing something like blog.com to newsite.com.
The basic things outside WordPress configuration:
- Purchase a new domain and point it to your host.
- Copy or move the files to the folder that was assigned to the new domain.
- Along with the domain, if you change the web host as well, make sure to copy the files as well as the database. Update the database information in wp-config.php.
Changing WordPress Settings
The first thing that needs to be done is to change the WordPress settings to point to the new domain. This can be done from different places:
If WordPress admin area is accessible
- Go to Settings > General.
- Change the value of WordPress Address (URL) and Site Address (URL) field to the new domain name.
If WordPress admin area is NOT accessible
After moving files to the location that is pointed to by a new domain, it is not possible to access the content through the old domain name. The new name hasn’t been set up in WordPress and so accessing the admin area won’t be possible. In such a case, the new WordPress address and site address can be hard coded in wp-config.php or theme’s function.php file.
Follow any one of these two methods:
1. For wp-config.php
- Access wp-config.php of the new domain using a file manager or ftp. This file is present in the root directory of a WordPress installation.
- Add these two lines to reflect your new location on the web:
[php] define(‘WP_Home’,’http://newsite.com’);
define(‘WP_SITEURL’,’http://example.com’);
[/php]
2. For theme’s function.php
- Using FTP or File Manager navigate to /wp-content/themes/<your-theme-name>/functions.php. Choose to edit this file.
- In the very beginning of the file, add these lines of code:
[php] <?php
update_option(‘siteurl’,’http://newsite.com’);
update_option(‘home’,’http://newsite.com’);
?>
[/php]
Remember to replace newsite.com with your actual new domain name. After the change is made and the file is saved, it will be possible to access the admin area using the new web address. Then, from the admin area, Settings > General change the WordPress Address (URL) and Site Address (URL) value to your new domain. You can now remove the hard coded address change information from wp-config.php or functions.php of your theme.
Changing Media and Links
Even though the site address information is changed in WordPress settings, the images and links that are present in posts will point to the old URL. This information is present in the site’s database and is not updated. That means all the images embedded in posts and pages will not load. The internal links that are present within posts and pages will also not work. A plugin should be used to batch update this information to contain the new domain URL.
We recommend the use of Velvet Blues Update URLs plugin.
Here are the steps involving this plugin—Velvet Blues Update URLs:
- Install the plugin from WordPress plugin directory.
- Go to Tools > Update URLs.
- Enter Old URL and New URL in the available input boxes.
- Tick all the URL update options except the last one.
- Click on Update URLs NOW and the changes will be processed.