How to Move WordPress from a Subfolder to Root Directory: Safe Methods to Move Your Site

Creating a website in a subfolder such as instead of the root folder of is useful for several purposes.

For example, you can create a staging site to replace a static site in a subfolder while the existing site is still functioning in the root folder. Or, you can install WordPress without filling up your root folder with additional files.

However, as your site grows, you may want to move the site to the root directory. This involves moving website files from the subfolder up one level, which can be a technical and risky process if you don’t do it correctly.

Thus, this article will provide you with a step-by-step guide to move WordPress from a subfolder to the root directory safely.

Download All in One WordPress Cheat Sheet

Before Moving Your WordPress Site

First and foremost, you need to have access to the web host control panel as you’ll move and make changes to the WordPress core files using it. Alternatively, you’ll need to install a File Transfer Protocol (FTP) client such as FileZilla on your computer.

The next important step is to backup your WordPress website and database. You should have a backup of the most recent version of your site so if something goes wrong when moving the website, you can resolve the issue easily and prevent loss of data.

Lastly, ensure that the root directory is clear of other or old site files such as index.php. They are not related to your WordPress site and will interfere with it.

If there are some old website files, download them for safekeeping or copy and paste them to a separate folder such as old_site_backup.

Moving Your WordPress Site to the Root Directory

There are two methods for WordPress migration to the root folder – using the file manager of your hosting provider or an FTP client. Since it’s going to be a major update to your site, consider unpublishing your WordPress site during the process to maintain a smooth user experience.

Moving WordPress From Subfolder to Root Directory With hPanel

The first method involves using the web host’s file manager. We will show you how to do that on hPanel, but the process is similar to moving a website using the cPanel file manager.

  1. Log in to your hPanel and find File Manager in the Files section.
File Manager on hPanel
  1. Go to the public_html folder.
public_html directory on file manager
  1. If there are existing WordPress files in the public_html folder, be sure to back them up first by copying and pasting them to a new folder.
  2. Go to the subfolder where your website is located. For example, if the website address is, there should be a subdirectory folder.
Subdirectory folder on file manager
  1. Press CTRL+A on Windows or Command+A on Mac to select all the folder content.
selecting all files on file manager
  1. Click on the Move button on the top panel of the File Manager.
The Move button on file manager
  1. Change the Destination directory to /domains/ and then click Move. Remember to replace with your actual domain name.
Setting up destination directory when moving files on file manager

Now, go back to public_html to see if all WordPress files and folders have been moved correctly.

Moving WordPress From Subfolder to Root Directory With FTP Client

The first step is to connect an FTP client to your website to move WordPress files. Here are the steps to do so with FileZilla:

  1. Log in to your hPanel and find FTP Accounts in the Files section.
FTP Accounnts menu on hPanel dashboard
  1. You will find the FTP access details such as FTP IP, hostname, and username.
FTP Accounts details
  1. If you don’t know the FTP password, click Change account password. It lets you reset the password without having to know the current one.
  2. Open FileZilla.
  3. Click the File menu at the top of the window and select Site Manager.
Site Manager on FileZilla
  1. Enter the credentials according to the FTP access details on hPanel, then click Connect.
Configuring Site Manager on FileZilla
  1. Once FileZilla successfully connects to your website, the website directory will appear on the Remote site section, and the website files will appear below it.
Remote site section on FileZilla

Now let’s move the website files from the subfolder to the root directory.

  1. Open the subfolder where your WordPress website is located. The common directory is domains -> -> public_html -> subdirectory. Just as in the previous method, be sure to back up any existing website files in the root directory.
Website directory on FileZilla
  1. Select all files, and drag and drop them to the public_html folder on the Remote site section.
Opening public_html directory on FileZilla

The process of moving the WordPress core files and folders may take time. Keep an eye on the status box at the top to see if the file transfer was successful.

Change Your WordPress Site URL

The next step is to change the site’s URL settings in the wp-config.php file so you can access wp-admin from the root domain.

The wp-config.php file on file manager

Open wp-config.php from your website directory and insert the following lines before /*

That's all, stop editing! Happy publishing. */ :

Replace with your actual domain name, then save and close the file.

Update Your URLs

After moving the WordPress website to the new directory, the permalinks may not work. Here’s how to fix broken permalinks via the WordPress dashboard:

  1. Log in to your WordPress admin dashboard and navigate to Settings -> Permalinks.
  2. Select another permalinks structure option. For example, switch from Post name structure to Plain. Then, click Save changes.
Permalink settings on WordPress dashboard
  1. Revert the setting to the previous option, for example, from Plain back to Post name structure. Click Save changes again.

Now, you have to update URLs on menu items and links on your website as they may still point to the old URL. Update them so that they point to the new domain address.

To avoid changing the URLs manually, install a WordPress plugin such as Go Live Update URLs. Once you’ve got it installed and activated, follow these steps:

  1. Go to Tools -> Go Live from your WordPress admin dashboard.
Go Live Update URLs plugin settings on WordPress
  1. Check all the tables to update old URLs in the database.
Updating URLs on databases
  1. Enter your old and new URL in the Old URL and New URL fields.
Changing URL on WordPress
  1. Click Update URLs.

Set a Redirect in Your .htaccess File

Even after you moved your WordPress site, some users may still use the old URL with the subdirectory. In this case, you have to set a redirect rule in your .htaccess file so that users who have the old URL will be automatically redirected to the new URL.

Doing this also prevents losing the results of your previous SEO efforts, as traffic to the old URL will be redirected to the new one.

Open the .htaccess file from your hPanel or FileZilla. The .htaccess file is located in the root directory and is often hidden. To show hidden files on FileZilla, navigate to Server on the top menu bar and select Force showing hidden files.

Option for force showing hidden files on FileZilla

Then, insert the following code in the file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule (.*)$$1 [R=301,L]

Replace and subdirectory with your domain and subdirectory name. If you don’t use www in your URL, make sure to write it accordingly in the RewriteRule line.


Moving a WordPress site from a subfolder to the root directory involves moving all of its core files. While the process is simple, it’s always best to create a backup of your data beforehand.

Once you are ready to move the website files, you need to choose whether to use the web host’s file manager or an FTP client.

After moving the files, remember to change the WordPress site URL in the wp-config.php file to be able to access the WordPress admin panel from the root directory.

Also, pay attention when writing your URL, whether you are changing the WordPress URL or setting a redirect in the .htaccess file. If you use www in the URL, you should write it accordingly, such as

If you have any questions about this process, feel free to leave a comment below.

The author

Leonardus Nugraha

Leo is a Content Specialist and WordPress contributor. Armed with his experience as a WordPress Release Co-Lead and Documentation Team Representative, he loves sharing his knowledge to help people build successful websites. Follow him on LinkedIn.