Skip to content

Moving a website from a subfolder to the main domain

Sometimes a website is built in a subfolder, so it opens at an address like example.com/new or example.com/wp. When it’s ready, you’ll want it to open at example.com instead. In these steps, replace example.com with your own domain and new with your folder’s name.

Make a backup of your files and database. If anything goes wrong, you can put everything back.

Your main domain loads from the public_html folder.

  1. In cPanel, open File Manager and go to public_html.
  2. Turn on Show Hidden Files in Settings (top right), so you can see files such as .htaccess.
  3. Move any old files you no longer need out of public_html, for example into a new folder called old-site. Leave your subfolder (new) where it is.
  1. Open your subfolder (public_html/new).
  2. Click Select All, then Move.
  3. Change the destination to /public_html and click Move Files.
  4. Check that index.php or index.html is now directly inside public_html.

WordPress:

  1. Log in to phpMyAdmin, open your site’s database and the wp_options table (the wp_ prefix may differ).
  2. Change siteurl and home from https://example.com/new to https://example.com.
  3. Log in to WordPress and update links inside your content with a search-and-replace plugin, replacing example.com/new with example.com.
  4. Go to Settings → Permalinks and click Save Changes. This rebuilds your .htaccess rules.

Other applications: update the site URL in your app’s settings or configuration file, then check .htaccess for any RewriteBase /new/ line and change it to RewriteBase /.

Ruachost servers run LiteSpeed, so pages may be cached. If you use the LiteSpeed Cache plugin, click Purge All, then clear your browser cache. Open example.com and click through a few pages, forms and images.

When everything works, you can delete the empty subfolder and the old-site folder.