Moving WordPress to the Root Directory of You Account

Many clients want to create their WordPress website outside of the public view and then move the WordPress site from a sub-directory to replace their existing site. This is a good practice but does have some technical challenges. Our administrators do this fairly regularly for clients and the cost is usually around $50 for standard sites (but can cost more for unconventional requirements).

Here’s how it’s done

The following discloses the secret sauce of what we do to make this happen. For the technically minded, you can save money and do it yourself. For the non-technically minded, you’ll understand the value of what you’re getting. The whole process takes between 30 minutes and an hour.

Caveat: You are responsible for actions taken from this point forward. We will gladly restore the account to the last good backup that we have at no extra charge. Technical support for any of the following is billable at $100 per hour if things get messed up even if our instructions are found to be the cause. We do not warrant any of the following in any way. That said, here’s how it’s done.

  1. Check to make sure there’s enough disk space. You should have a ratio of 30 to 70% of used and open disk space because you’ll be (temporarily) duplicating your current usage twice.
  2. Optional: We ask that you create a new Admin user so that you can lock us out after the process is complete. This protects you and our staff.
  3. Make sure all software, plugins, and themes are up to date and tested. Outdated software is the most common vector for hackers to take over your website.
  4. Make sure your account is backed up so you can restore it if things go bad. Note that we backup all sites each night. If it’s after 7:00 a.m. your site’s been backed up.
  5. Copy the /public_html and all of it’s contents to a new directory called public_html.out . This is for backup purposes but also so you don’t lose your old site files if you should need them.
  6. Delete all unnecessary files in the /public_html directory. For example, all the files from your old site. Note that at this stage your website won’t work so keep going.
  7. Copy (don’t just move) all the files from your wordpress subdirectory. From this point forward we’ll use “WPSUBDIRECTORY” to represent that directory name. If you named the subdirectory “wp” or “wordpress” or some term that is likely to be in the wordpress database, stop and ask for professional help as the following steps will destroy your site.
  8. Search and replace all instances of /WPSUBDIRECTORY and WPSUBDIRECTORY/ (note the slashes) in the wordpress database. We specifically use the plug in “Better Search Replace” from https://wordpress.org/plugins/better-search-replace/ for this purpose. But you can use any tool you wish including PHPMyAdmin included in your control panel. This changes the URLs for your site throughout the database, changing http://use-your-domain.com/WPSUBDIRECTORY/ to http://use-your-domain.com/
  9. Search the database again for WPSUBDIRECTORY just to make sure it’s been removed from the database using PHPMyAdmin. Change those as needed.
  10. Change the URLs in the WordPress Dashboard > Settings > General to the root of the site.
  11. Check and change any references to WPSUBDIRECTORY in the .htaccess file using the File Manager tool in your control panel (note, make sure you turn ON the option to view hidden files because the .htaccess file is hidden).
  12. Test the new site without the WPSUBDIRCTORY name in the URL. You may need to restart your browser to remove any cached info.
  13. After you’ve worked out any bugs in testing, rename the /public_html/WPSUBDIRECTORY to /public_html/WPSUBDIRECTORY.out so that we can make sure WordPress is no longer using anything in that directory.
  14. Test the site again.
  15. If everything is working, you can delete the /public_html.out and the /public_html/WPSUBDIRECTORY.out  directories.
  16. Reduce the disk space as needed if you’ve had to add disk space to the account.