Sometimes, it happens you want to change your website’s URL address to a new domain and URL, either because you or your client changed business name or simply because the old one is compromised for any reason and you want to move to a new address and keep your website exactly the same and only change references to the old name and address.
Before starting, make sure both domains (oldsite.com and newsite.com) are hosted somewhere. It is not important if hosting servers are at same account or different ones. The “old” site is where the current full website is running and the “new” site is where you are going to duplicate/clone the “old” one to.
Step 1 – Clone your site
Create a clone package of your current website with your preferred duplication/cloning plugin, like the excellent Duplicator plugin.
Download your package from your current site’s server and upload it at the new location (newsite.com). Depending of the plugin you’ll be using, you might need to start a fresh empty WP installation at new site or, if using Duplicator, just create a new database that will be used for the new site.
Once the duplication process is over, just login to the new site as admin and make some basic changes to the site’s title and tagline for instance and check that everything is running smoothly.
Step 2 – Run a search-replace at your new site
Your new site is now a duplicate of the old one and thus still has references to the old domain and business names. Those references may be found in several locations, links, posts or pages and not only in WP settings.
The simplest and best solution for replacing those terms in the database is by installing and running the very popular Better Search Replace plugin.
First you need to enter the term or name you want to search for and the new one in below in replacement of the above. It is recommended to first run the plugin in “dry mode”. That way, no changes will be made and it will display the search results before proceeding with the actual replacement of the terms you have chosen.
Repeat the same process for every term you want to replace.
Once this is done, your new site is ready and you now need to setup a permanent redirection for visitors, from the old site to the new one you just finished setting up.
Step 3 – Set up a permanent 301 redirection (Apache servers)
Connect to the old site by FTP and edit your .htaccess file by adding the following code at the top of the file’s content:
#Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ http(s)://newsite.com/$1 [R=301,L]
You have to use the correct URL for your new site according to the settings you have setup in WP: with or without “www”, with or without HTTP(S). And if the old site was on HTTPS you should maybe also install an SSL certificate at the new site so that the redirection follows the same logic.
This will permanently redirect all visitors from the old site to the new one.
Step 4 – Add your new site to Google/Bing and remove the old one
Adding your new site to Google & Bing is done the same way you have done previously for your old site. Just add the new site, with its new URL address, as usual.
At this point, Google/Bing will have references for both of them and it is important now to remove the old site from there in order to avoid complications with duplicate content, as both sites will have about the exact same content.
For doing so, just follow the official Google guide and related steps for adding and removing existing properties in Google Search Console.
For Bing, you have a similar procedure to follow at Bing Webmaster Tools page:
Go to your Dashboard and click on “Block URLs” and then follow the instruction at that page.
The information tooltip after the title will notify you about the following:
“This feature allows you to block a URL from appearing in the Bing search results. This block will remain in place for 90 days. If the URL still returns a 200 OK code when visited by our crawler after 90 days, it will reappear in our search results. “
As you have already implemented a permanent redirection at old site, everything should be fine.
It is recommended to keep the old site active with the redirection for about one more year, in order to have visitors still having your old URL in their bookmarks redirected properly to your new site.
* * * * *