1. Create a Full Backup of Your Site
Before you make any changes to your WordPress site, it’s important to create a full backup of your site. This will ensure that you have a copy of your site in case something goes wrong during the move. You can use a plugin like UpdraftPlus to create a full backup of your site.
2. Move the Files
Once you have a full backup of your site, you can start the process of moving the files from the subfolder to the root directory. To do this, you’ll need to use an FTP client like FileZilla. Connect to your server using the FTP client and navigate to the subfolder where your WordPress site is located. Select all the files and folders in the subfolder and move them to the root directory.
3. Update the WordPress Address and Site Address
Once you’ve moved the files, you’ll need to update the WordPress Address and Site Address in the WordPress admin dashboard. To do this, go to Settings > General and update the WordPress Address and Site Address fields. Make sure to include the full URL of your site in both fields.
4. Update Your .htaccess File
The .htaccess file is a configuration file that controls how your site is accessed. You’ll need to update this file to ensure that your site is accessible from the root directory. To do this, you’ll need to use an FTP client to connect to your server and edit the .htaccess file.
5. Update Your Database
The last step is to update your database. This is important because your database contains all the information about your site, including the URLs. To update your database, you’ll need to use a plugin like WP Migrate DB Pro. This plugin will allow you to update all the URLs in your database from the old subfolder URL to the new root directory URL.
Once you’ve completed all these steps, your WordPress site should be successfully moved from the subfolder to the root directory.
Creating a website in a subfolder such as www.example.com/subdirectory instead of the root folder of www.example.com 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.
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.
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.
- Log in to your hPanel and find File Manager in the Files section.
- Go to the public_html folder.
- 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.
- Go to the subfolder where your website is located. For example, if the website address is www.example.com/subdirectory, there should be a subdirectory folder.
- Press CTRL+A on Windows or Command+A on Mac to select all the folder content.
- Click on the Move button on the top panel of the File Manager.
- Change the Destination directory to /domains/example.com/public_html and then click Move. Remember to replace example.com with your actual domain name.
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:
- Log in to your hPanel and find FTP Accounts in the Files section.
- You will find the FTP access details such as FTP IP, hostname, and username.
- 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.
- Open FileZilla.
- Click the File menu at the top of the window and select Site Manager.
- Enter the credentials according to the FTP access details on hPanel, then click Connect.
- 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.
Now let’s move the website files from the subfolder to the root directory.
- Open the subfolder where your WordPress website is located. The common directory is domains -> example.com -> public_html -> subdirectory. Just as in the previous method, be sure to back up any existing website files in the root directory.
- Select all files, and drag and drop them to the public_html folder on the Remote site section.
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.
Open wp-config.php from your website directory and insert the following lines before /*
That's all, stop editing! Happy publishing. */ : define(‘WP_HOME’,’http://example.com’); define(‘WP_SITEURL’,’http://example.com’);
Replace example.com 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:
- Log in to your WordPress admin dashboard and navigate to Settings -> Permalinks.
- Select another permalinks structure option. For example, switch from Post name structure to Plain. Then, click Save changes.
- 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:
- Go to Tools -> Go Live from your WordPress admin dashboard.
- Check all the tables to update old URLs in the database.
- Enter your old and new URL in the Old URL and New URL fields.
- 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.
Then, insert the following code in the file:
RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com/subdirectory$ [OR] RewriteCond %{HTTP_HOST} ^www.example.com/subdirectory$ RewriteRule (.*)$ http://www.example.com/$1 [R=301,L]
Replace example.com 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.
Conclusion
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 www.example.com.
If you have any questions about this process, feel free to leave a comment below.
How to Move WordPress from a Subfolder to Root Directory: Safe Methods to Move Your Site
If you’ve been running your WordPress site from a subfolder, you may be wondering how to move it to the root directory. Moving WordPress from a subfolder to the root directory is a relatively simple process, but it’s important to take the necessary precautions to ensure that your site remains secure and functioning properly.
Why Move WordPress to the Root Directory?
There are a few reasons why you might want to move your WordPress site from a subfolder to the root directory. For one, it can make your site easier to access and navigate. Additionally, it can help improve your SEO rankings, as search engines tend to favor sites that are located in the root directory.
How to Move WordPress from a Subfolder to Root Directory
Before you begin the process of moving your WordPress site from a subfolder to the root directory, it’s important to back up your site. This will ensure that you have a copy of your site in case something goes wrong during the move. Once you’ve backed up your site, you can begin the process of moving it to the root directory.
Step 1: Copy Your WordPress Files
The first step in moving your WordPress site from a subfolder to the root directory is to copy all of your WordPress files from the subfolder to the root directory. You can do this using an FTP client or by using the File Manager in your hosting control panel.
Step 2: Update Your WordPress Address and Site Address
Once you’ve copied all of your WordPress files to the root directory, you’ll need to update your WordPress Address and Site Address in the WordPress dashboard. To do this, go to Settings > General and update the WordPress Address and Site Address fields to reflect the new location of your WordPress site.
Step 3: Update Your Database
The next step is to update your database to reflect the new location of your WordPress site. To do this, you’ll need to access your database using a tool like phpMyAdmin. Once you’ve accessed your database, you’ll need to update the “siteurl” and “home” fields to reflect the new location of your WordPress site.
Step 4: Update Your .htaccess File
The final step in moving your WordPress site from a subfolder to the root directory is to update your .htaccess file. This file is located in the root directory of your WordPress site and it controls how your site is accessed. You’ll need to update the .htaccess file to reflect the new location of your WordPress site.
Conclusion
Moving WordPress from a subfolder to the root directory is a relatively simple process, but it’s important to take the necessary precautions to ensure that your site remains secure and functioning properly. By following the steps outlined above, you can safely move your WordPress site from a subfolder to the root directory.