Have you ever thought about changing your WordPress blog domain name? Well, if you want to, the guide below will show you how to do it. This post describes the steps you should take when you want to switch to a new and different domain name for your WordPress blog.
For this post, we’re going to be switching from myexamplewp.com to mynewexamplewp.com.
When you’re ready, continue below to start the process.
Step 1: Registering for new domain
While your existing domain is still functioning, go and register for the new domain. Your goal is to limit the downtime for your sites. Since you already have an existing domain, we assume you know how to register for one.
At your current domains provider, go and register for the new name or you can use a different provider. Since you’re only switching the domain name here, all WordPress content will stay in the same place.
The new domain will probably come with a new IP address. It may also take about 24 hours for the new domain to be ready.
Step 2: Changing WordPress URL or Permalinks
When the new domain name is ready and can be accessible around the world, your next task will be to go and change WordPress URL to reference the new domain. When you change the URL in WordPress to the new domain, the old domain name will not be pointed to your WordPress content.
To switch the name, logon to the admin dashboard usually at http://myexamplewp.com/wp-admin
There, click Settings and select General
In the WordPress Address (URL) and Site Address (URL) as shown in the image below, type the new URL to replace the existing one.
Save the changes and your current session will end. Now, use the new URL for the admin dashboard to logon to WordPress.
If everything is setup correctly, the new URL will be the default URL to access your content.
Or you can edit WordPress’s wp-config.php file via FTP or command line terminal and add the highlighted lines below to change the URLs:
/* That's all, stop editing! Happy blogging. */
Step 3: Resetting WordPress Permalinks
Logon to the admin dashboard using the new URL and select Settings then Permalinks. On the Permalinks page, select another permalink settings other than the one you previously used and save the changes. If that works, go and select the previou (original) Permalink and save, and you’re done.
Step 1: Backup WordPress database
The same process above can be accomplished via WordPress database. If you have direct access to WordPress database, continue below to use the database to make the same changes above.
First backup WordPress database by running the commands below:
mysqldump -u root -p database_name > database_backup.bak
Step 2: WordPress Address (URL) and Site Address (URL)
Logon to the database by running the commands below.
mysql -u root -p
When prompted for password, type it to continue.
When you’re logged-in, run the commands below to change WordPress Address (URL) and Site Address (URL)
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://www.oldsite.com', 'http://www.newsite.com');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'http://www.oldsite.com', 'http://www.newsite.com');
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://www.oldsite.com', 'http://www.newsite.com');
Exit and you’re done.
The database method is the most effective and will get the job done correctly with little problems.
After the site is accessible the new domain, go to your current domain host and setup a domain forwarder. This will forward all users using the old name to the new domain. This is how it’s done and hope the best for you.