How to Move WordPress from a Subdirectory to the Root Directory?

How to Move WordPress from a Subdirectory to the Root Directory?

Many WordPress users prefer to set up and test out a new version of their websites within a subdirectory, and this step-by-step guide will explain how to move your well-established WordPress install from a subdirectory to the root/main folder. Note that, this migration process can be done within a couple of simple steps.

Now, let’s go through the whole process with vivid screenshots included.

Step 1 – Make Backups of Your WordPress Site

To transfer your new site built in a subdirectory like over to the main folder of the domain like is not as tricky as you may suspect. And instead, you can achieve this outcome by using two different ways – changing website URL and migrating all WordPress files. Whichever method you decide to use, you should make a prior backup of your WordPress site before implementing the following procedure. Make sure that the backup files will be stored on your local hard drive.

Step 2 – Update Your WordPress URL Settings

Assuming that you’d like to migrate all WordPress related files, you will have to login to the admin interface to change the old URLs. Upon entering, navigate to “Settings” > “General” so that you can update the WordPress URL settings. In the following screen, change the “WordPress Address (URL)” and “Site Address (URL)” into your domain name. In another words, you need to remove the attached “ID Directory” like /wp from here. This will tell WordPress the new URL of your website.

Update Your WordPress URL Settings

When you click the bottom “Save Changes” button, an error message will pop up on the screen. This is quite common and to be expected. Ensure that you’ve removed all existing files from the main/root directory before starting copy your WordPress files.

Step 3 – Move WordPress from a Subdirectory to the Root

Now that you’ve done with the preparations for your WordPress migration, it’s time to move the subdirectory to your domain root. To do this, log onto your cPanel interface and go to “Files” > “File Manager” as below. Beware that, the box that reads “Show Hidden Files” should be checked from this dialogue window.

Show Hidden Files

After that, you are required to enter the folder where your WordPress has been installed. If done correctly, there will be a full list of WordPress folders and files from the right-side of this “File Manager” page. Just highlight and select all included folders and files and press the “Copy” button from the upper-right toolbar as follows.

Press Your Copy Button

This will bring a pup-up that prompts you to fill in the destination folder. Just change the default WordPress folder like public_html/howshost to the new path like public_html. Once this is done, click the “Copy Files” button to move the files over to the main public_html folder.

Confirm Your Destination Folder

After the completion of this process, you can hit the “Up One Level” option to revert back to the mentioned public_html folder. If everything is in working order, you will see the same folders and files that are stored within the previous WordPress folder. Do not delete the subdirectory until your website is totally migrated.

Step 4 – Update Old URLs & Permalinks

The last step is to fix the image or document URLs. If you’ve uploaded any files or images through the inbuilt WordPress uploader, chances are that you will have serial old URLs that contain the ID directory like /wp. To correct those outdated URLs and remove all your database references, you may use a handy plugin named as Velvet Blues Update URLs from the plugin repository.

About Velvet Blues Update URLs

Also, the custom permalinks should be updated accordingly from your admin interface. This step is quite necessary as it will update the .htaccess file located at the WordPress home directory. If you don’t update permalinks after the migration, you may find the dashboard is inaccessible eventually.

Update Your Permalinks

As is implied, you would go to “Settings” > “Permalinks” to relieve yourself from this embarrassing situation. Keep in mind that the selected link structure should correspond to your new URL. Till now, you are all set and your site can be loaded from the new location.