How to Move WordPress from a subdirectory
Follow the below steps to move a WordPress installation from a subdirectory to the root directory:
Backup your website: Before making any changes, create a backup of your WordPress site files and the associated database.
Copy files: Log in to your cPanel account and using FTP (File Transfer Protocol) or a file manager. Find the subdirectory where your WordPress installation is located. Copy all of the files and folders found in that subdirectory to the root directory. Depending on how big your website is, this process might take some time.
Update site URL: Login to the WordPress admin dashboard and go to “Settings” > “General.” Find the “Site Address (URL)” and “WordPress Address (URL)” fields. Both fields should now point to the root directory by removing the subdirectory path. Replace http://yourdomain.com/subdirectory, for instance, with http://yourdomain.com. and Save the changes.
Edit the “.htaccess” file: To ensure proper redirection, you must update any custom.htaccess files located in the root directory. Open the root directory’s “.htaccess” file in a text editor. Identify any lines that make reference to the subdirectory and change them to reflect the new file path.
For example, change RewriteBase /subdirectory/ to RewriteBase /. Save the changes.
Check out your website: To confirm the successful transition from the subdirectory to the root directory, test various website pages, links, and functionalities of the website.
After the migration, it’s important to check everything again to make sure your website is working properly. Having a backup will let you go back to the previous state if you experience any issues.