This article explains how to move WordPress from the root directory to the subdirectory.
At times, you might want to install WordPress in the root directory (wwwroot/public_html) but choose not to mess it with WordPress files and folders. Under these circumstances, you can set up a subdirectory for your WordPress installation while still helping your website from the root folder.
For instance, you can install WordPress in the directory “sample.com/mywebsitee” and access your site through the URL “http://mywebsitee.com”.
Here’s how to do it in a few simple steps:
- Create a Subdirectory:
Start by creating a folder where you want to install WordPress. In this tutorial, we will use “/mywebsitee”. - Update General Settings:
In your WordPress dashboard, go to Settings >> General Settings.
- Change WordPress Address:
In the WordPress Address (URL) box, update it to the new location of your main WordPress core files (e.g., http://sample.com/mywebsitee). - Set Site Address:
In the Site Address (URL) box, change it to the root directory URL (e.g., http://sample.com) and click “Save Changes”.
- Move WordPress Core Files:
Move your WordPress core files to the new location “/mywebsitee” folder. - Copy Important Files:
Copy (do not move) the “index.php” and “.htaccess” files from the “/mywebsitee” folder to the root directory (i.e., wwwroot/public_html). - Show Hidden Files:
By default, the “.htaccess” file may be hidden. Make sure your FTP client is set to show hidden files. If you are using cPanel’s file manager, check the box to show hidden files.Note: If you are not using Pretty Permalinks, you may not have a “.htaccess” file. If you are on a Windows (IIS) server, you will have a “web.config” file instead.
- Handle the index.php File:
Copy (do not move) the “index.php” file to your root directory. - Move the web.config File:
For the “web.config” file, move (do not copy) it to your root directory. - Edit the index.php File:
Open the “index.php” file in the root directory with a text editor. - Update the Require Statement:
Replace this line:require( dirname( __FILE__ ) . '/wp-blog-header.php' );
With the following line, insert your subdirectory name:
require( dirname( __FILE__ ) . '/mywebsitee/wp-blog-header.php' );
- Access the New Dashboard:
Browse to the new WordPress dashboard at “http://sample.com/mywebsitee/wp-admin/” to log in. - Update Permalink Structure:
If you have set up Permalinks, go to “Settings >> Permalinks Settings” in the WordPress dashboard, select your previous permalink structure, and click “Save Changes.”
That is it! Hope you liked our article. If you require additional support, seek help from our support staff.