Move WordPress from subfolder to root
In order to move your WordPress installation to another directory, you need to execute a few steps.
This will allow for example to move the WordPress installation from a subfolder to the root folder, or the way to move it a new domain, but moving the files to the folder corresponding to this new domain name.
If you move WordPress from localhost to server, you might also have to perform these actions, as the relative folders on your local computer and on the server in cPanel are different.
1 – WordPress change URL
On your admin page, go to Settings of the Wordpress installation.
Wordpress blog sites
There, change the WordPress Address (URL) and Site Address (URL), to match with the target folder – in below example, installation is moved from root folder to a sub-folder named v2.
Then, using your file explorer for a local site (i.e. on XAMPP), or your FTP client (i.e. FileZilla) if the site is online, move the whole WordPress installation, all WordPress files, to the destination folder.
2 – Wordpress move from subfolder to root
Open the file index.php from WordPress folder, and find the following line:
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
Change it to match your new folder, as per below example:
- ./v2/wp-blog-header.php – if installation has been moved in a sub-folder,
- ../[folder]/wp-blog-header.php – if installation has been moved in a parent folder.
3 – How to transfer WordPress site from localhost to live server
You can now try again to access your with the new URL you have entered in the first step!
If you have uploaded your site from localhost to a cPanel live server, for example using FileZilla, you must do this manipulation to have the site work.
It must be now possible to access the WordPress site at requested WordPress site URL, and the site should be displayed as per below example:
FileZilla the free FTP solution
Install WordPress in subfolder
It might not work directly on your browser when trying to access it, for cache reason. In case it doesn’t, try accessing the URL with another browser, it will correct itself after the cache will have expired.
Another way to make it work can be to delete the cache on your browsers, and, if doing a WordPress migration to a new server, it might also be necessary to clear DNS cache on your Windows installation.
If you have install WordPress in subfolder, and want to to move it to root folder, to a new domain, a new URL, or a new hosting server, it is always necessary to migrate WordPress site the same way, as long as the folder in which WordPress is stored has changed.
WordPress change site URL
When changing the WordPress site URL in the administration menus, pay attention, as it will as well change WordPress admin URL, which can then be accessed only using the new URL of the WordPress site.
Same happens actually after a WordPress change domain, the admin URL will be changed accordingly, as the whole WordPress site is now accessible only at that new URL.
See also how to move wordpress site to new domain
Move wordpress site to new domain
International SAP & Web consulting Wordpress blog in subfolder
WhereCanIFLY travel blog moved to Wordpress subfolder
Travel Comparator Wordpress ready to move to root folder
Help Smartphone Wordpress not moved to root folder