There are not many times when you should be altering the domain name in your WordPress installation but can still be required. Maybe you have simply found a much better domain name that suits your website. In my case, I migrated my site from Joomla to WordPress and it was not possible to use a plugin to transfer all of the photo galleries. It made more sense to develop a whole new site first in WordPress and then migrate it when complete.
Case Study: Two domains in shared hosting account.
An important distinction here is that these instructions are for someone in a shared hosting environment. If you have full access to the apache web server, you would simply develop the new site completely and change the DNS to point at the directory the new domain is in and you would be done.
In my case, I am required to have my main domain in the root of the public_html folder at my hosting provider. This is what I did to switch from Joomla at “kimbriggs.com” to WordPress, which we will say was in a add-on domain, “fakedomain.com” in the folder “2023BU”.
- Installed a WordPress instance in 2023BU and spent a lot of time creating a new site.
- When completed, I created a copy of the new site using Softaculous “Create Staging” function.
- Used the WordPress plugin “Better Search and Replace” on the staging copy to change every instance of “fakedomain.com” to “kimbriggs.com”. You need to select every table AND check the box to change the GUID columns as well (against the best warnings of many others) because your really do want to get rid of all references to “fakedomain.com”.
- Go to the “staging” homepage and check to see that the URLs have changed to the one you want. If not, be glad you were working on a staging copy and try a different method.
- If Search and Replace worked, I *think* you also need to go into the changed site’s WordPress andinistration panel, go to Settings, and update both WordPress Address and Site Address to the new domain. That might be all you need to do if you don’t have Joomla involved and are willing to experiment on your live site, but experimenting on a live site is not usually a good idea.
- In the case of replacing my Joomla installation, the site needed to be down for a short while while the next steps were taken. I first created a directory in public_html and moved all files having to do with the Joomla installation there.
- I then copied all the files in the WordPress directory with the updated domain name “kimbriggs.com”(1). This worked in terms of serving up the new website right away but there was still work to do on the server side because when I went to make a backup of the new site in Softaculous the “Installation URL” was pointing to the wrong directory.
- If you don’t spend a lot of time in Cpanel, at this point you might not know how to change this because you believe you are in the “WordPress Manager” doing all your WordPress management. The trick is you have to go to the Softaculous “home” page and go to the top where is says “All Installations”. Then, when you see the WordPress install you want to modify, select the “Edit” button to the right. You can then change the directory where Softaculous will look for the installation and you will backup the correct version.
I hope this helps you get done what you need to do but remember not to do anything to your site until you have made a complete backup and you know how to restore it from that backup!
(1) The first time I tried changing the domain name I used the WordPress plugin “Better FIND and Replace”. It did change some URLs but I *think* I needed “Better Search and Replace” with the check box that allows for changing the GUID.