This article is mostly for my own use, but perhaps you’ll find some use for it too! These are just the steps I take to ensure that all of the URLs and site information are correct for the live site vs. the test location.
When I set up a test site on Cloud Access that is later to go live on the same server, I initially set it up to use the proper, live URL. Since Cloud Access has the feature where you have an alternate url at cloudaccess.net, this allows us to work on the site even if the domain is not yet pointed to this host.
The problem is, unless you search and replace many links within the database, every time you try and go anywhere, it will forward you to the live URL (which for now is on a different server). So how do I get around this? By adding the following lines near the bottom of wp-config.php (right above the line that says, “That’s all, stop editing!”)
Tired of dealing with your slow WordPress website? Email me at firstname.lastname@example.org and mention the code #FreeHosting10 for two free months of lightning-fast WordPress hosting. We will even migrate you for free!
Obviously you would replace your the URL here with your site’s temporary URL. With that change, it will force everything to stay at the test location for now.
So how do we then go live with this site? You guessed it! You just remove these two lines.
There’s still more to do, however! There may still be many links throughout the site pointing to the test location. We want to search and replace all of those. Luckily, Cloud Access gives us a tool to do just that! Here is how we do that: (Note: I highly recommend you back up your database before doing this. To do so, get to PHPmyadmin from Cloud Access and export it directly from there)
1. Log in to your Cloud Access Account
2. Click “Manage” next to the domain you are working with.
3. Click “Application” and then “Database” from the dropdown menu.
4. In the bottom-right, click “Find & Replace Tool”
5. Select “All” to check all tables.
6. Enter in your search term. This will be the old url, e.g.: casite-123456.cloudaccess.net
7. After clicking search, enter in your Replace Term. This will be your domain name, without http:// or a trailing slash, e.g.: example.com
8. Click “Replace” if everything looks right.
Then, there’s only one thing left to do. It’s probably not absolutely required most of the time, but it can help flush out problems. All you need to do is reset your permalinks!
From the WordPress backend, go to Settings -> Permalinks, then just click “Save Changes” without actually changing anything! This will reset any menu links and other WordPress links to ensure they point to the current, correct spot.