How to move your WordPress installation from a sub-directory to root folder from WordPress

What is the need of moving WordPress from Sub-directory to Root folder?


Sometimes by mistake you have install your WordPress to WP folder/sub-directory. In this case your website will be visible at yourdomain.com/subdirectory. But if anyone search your website at yourdomain.com the will show an error message. So to make your website visible without sub-directory you need to move your WordPress at the root folder.

How to move your WordPress to root folder from WordPress dashboard?


To move your WordPress from sub directory to root folder you need to do the following steps:

Step1: Login to your cPanel.

Step2: Scroll down to the Files section and click on “File Manager”.

Step3: Now click on “public_html” folder at the left side of the panel. A list of files & folders will open.

Step4: Open “WP/sub-directory” folder from the list in which you have installed WordPress and Select .htaccess & index.php file then click on “Copy” icon at the top navigation bar.

Step5: A dialog box will appear. In the dialog box remove the sub-directory and keep here public_html only. Then click on “Copy File(s)” button.

Step6: Navigate to public_html root folder and “edit” copied index.php file.

Step7: After Finding require( dirname( __FILE__ ) and replacing ‘/wp-blog-header.php’ ); with ‘/yoursubdirectoryname/wp-blog-header.php’ ); click on “save” button.

Step8: After that login to your WordPress.

Step9: Move your cursor at “Settings” at left side and click to “General”. A new page of General settings will open.

Step10: In the “Site Address (URL)” remove your sub-directory name from the URL and keep only your domain name.

Step11: Scroll down and click on “Save Changes” button.

Now you can logout your WordPress as well as cPanel after checking your website by accessing without sub-directory.