I just launched a site for a client and they decided to use their own hosting company which I was more than happy to work with. They set up a sandbox server for me to use and once we got everything up and running smoothly the host changed the domain name from a staging.sitename.com to www.sitename.com
If you are familiar with WordPress you know that you need to change the main settings in General — from staging.sitename.com to www.sitename.com – once you take the site live.
You might think this would fix the problem but it can create problems in certain situations. In this case, my client had problems seeing the images on their own internal offices because the way the server was setup did not allow them to see the images because the images were linked to “staging” instead of “www”.
The solution is a simple plugin called Better Search and Replace.
Before you touch your site, make sure you backup your site using a tool like managewp.com. You can never have too many backups. EVER.
Then go ahead and install the plugin to your plugin folder and activate it.
You will find the plugin under -> Tools – > Better Search and replace. Go ahead and click on that for options.
You will see the screen below. Simply put in what to search for. In this case, I was looking for the text “staging.sitename.com”
Then put in what you want to replace it with. For this example, I want to put in “www.sitename.com”.
Next, you will need to select the tables you want to search and replace. Select all of them if you are unsure. (and remember, you have made a backup prior to touching anything here so you have a fail-safe in place in case something goes wrong)
The selection “Run as a dry run” is set up for you. If you keep the settings as they are, it will do a test run to see what results come up. You will be able to check to make sure you have the correct change in place. Once you are sure, deselect this checkbox and run the “search/Replace” again and your changes will be made.
ut you might also have placed images on the site that still have the absolute value of “https://staging.sitename.com/wp-content/uploads/2016/12/image.png”