Build Site vs Live Site

From time to time we’re asked to migrate a WordPress website that a client has installed in a subdirectory to their primary website. Typically the process takes about hour to complete, unless they don’t plan ahead. Here I’m going to share the basic steps to preparing a site that you know you’re going to move a WordPress site from a subdirectory to your main website (also known as the root directory of the account) and some tips along the way that will make things to smoothly. I’ll also provide the the names of the tools we use to do so and if you’re have the initiative you can do it yourself.

Rule #1: Don’t use the default directory provided by Softaculous.

Softaculous wants to make sure you don’t accidentally overwrite your current website by accident. So by default, it provides a subdirectory to install into called “wp”. Part of the process of moving your site to the root directory of the account involves changing hundreds of entries in the database that refer to the this subdirectory. If you name it something that is likely to be in other areas of the WordPress database a search and replace will replace every entry that has that term. I assure you, naming the directory “wp” or “wordpress” will mess things up when a search and replace is done. So, name it something like “demo1” or “tempsite” because these are not in the database.

Now, go about creating your site.

Here are the steps I use to move the site from a subdirectory to the main site.

The fine print: we do not warrant anything that follows to be correct in any way. There will be a fee for services if you want us to correct any errors introduced by following these instructions. Nothing that follows falls under our regular tech support services. If any of these warnings concerns you, then please do not proceed.

The following assumes you put WordPress in the demo1 directory.

  1. Download and install and activate the “Search & Replace” plug-in by By Inpsyde GmbH.
  2. Copy all the directories and files to the root directory of your site.
  3. Log into your Dashboard > Settings and remove demo1 from the “WordPress Address (URL)” and “Site Address (URL)”
  4. Use the “Search & Replace” plug-in by By Inpsyde GmbH to replace all instances of “/demo/” with “/” and then all instances of “/demo” with “/”.
  5. Log out of your dashboard.
  6. Edit your .htaccess file and remove all references to /demo and change them to the root directory instead.
  7. Test the site in the root directory. If it works, continue.
  8. You are NOT done. If things are working you may be tempted to stop. Here’s why that’s a bad idea. If you’ve left all your old files in the demo1 directory and if hackers search they can find those files months from now when the software is old and an exploit has been found. They can then use the old software to hack your site even though you’ve upgraded the software in the root directory.
  9. Rename the demo1 directory to demo1.out.
  10. Now test the site again in the root directory. Also log into the dashboard. If it works you’re almost done.
  11. Make sure everything is working as it was before. If you do this right away and there’s a major problem, you can request that the site be restored back to the original. If you wait too long, that might not be possible.
  12. If everything is working fine after a week, you can safely delete the demo1 directory.
  13. Now you’re done. Go buy a kitten.

Often there’s something unique that doesn’t fall under the typical steps above. Maybe there was a custom edit to the .htaccess, wp-config.php or index.php file. This will become known after the fact and can usually be corrected with a little sleuthing.