Mostly new version of the WordPress website created at the subfolder, so that it does not affect the main domain. Once completed, how to migrate the new site over to the root directory for the domain.
Follow the instructions below as we guide you on how to move WordPress from a Subfolder to the Root Directory.
Make a Backup of your account
Before moving data need to take the backup of your website.
Moving Website data
First, you need to connect to your website using an FTP client or cPanel’s file manager. Once connected, go to your subfolder location and download all your WordPress files to your computer.
Next, open the public_html folder of your root domain. Depending on how your WordPress hosting environment is setup, this folder could also be named www or after your domain name. Now, you need to upload all WordPress files you downloaded earlier to the root directory.
Change WordPress URL and Site URL Settings
Prior to physically moving the files, you will need to prepare the installation to accept the new URL name.
- Log into your WordPress Dashboard.
- From the main dashboard, go to Administration -> Settings -> General.
- Next, look for the WordPress address (URI): and change it from (example.com/WordPress to example.com)
- Look for the Site Address address (URL): and change it from (example.com/WordPress to example.com)
To fix this, switch to the FTP client and go to the root directory of your domain name. Next, you need to edit the wp-config.php file and add the following lines just before the line ‘That’s all, stop editing!’.
Redirect All Subdomain Traffic to The Root Domain
Now that you have moved WordPress files, let’s make sure that your subdomain traffic is redirected to the root domain name. Go to your subdomain folder and make sure that hidden files are forced to be visible.
Your FTP client settings have an option to always show hidden files. In FileZilla, it is located under ‘Server > Force Showing Hidden Files’ option.
If you are using cPanel File Manager, then click on the Settings button at the top right corner of the screen. This will bring up the preferences popup. You need to select ‘Show hidden files’ and then click on the Save button.
If your subdomain folder already has a .htaccess file, then you can delete it and create a new one. Inside the new .htaccess file, you need to copy and paste the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^yoursubdomain\.example\.com$ [NC]
RewriteRule ^(.*)$
"http://example.com/$1"
[R=301,L]
</IfModule>