For this example, suppose you were running WordPress website on the ROOT directory of your host or server, and you would like to move it to a sub-domain or a sub-directory, then follow the following steps. As we are moving the WordPress site within the same server, there is no need to move the database.
MOVING THE WORDPRESS FILES
I have separately mentioned sub-domain and sub-directory, because they are sightly different. Sub-domain means you want the site to be accessed using http://subdomain.domain.com. And sub-directory means you want to access the site using the URL http://domain/subfolder .
That is the only difference, otherwise, both will have the same sub-folder under root. And the process is the same to move the files.
- Move all the WordPress files to the sub-directory
Take care if there is any other files other than WordPress in the root directory, such as files from another sub-directory and others. WordPress creates three main folders "wp-content", "wp-admin' and "wp-includes". Besides the three folders there will be a few other ".php" files. Don't miss out any of those files.
After you have finished moving the WordPress files, you sites should now be accessible with the URL http://subdomain.domain.com if you have created a sub-domain or http://domain/subfolder if you did not create a sub-domain.
By accessing the site using any of the URLs above, you would realize that the site is not displaying correctly. That is because, when you first installed the WordPress site, the site URL is set to the main domain http://domain.com. We need to change that.
- Changing the WordPress Site's domain in MySql database using phpMyAdmin
- Once in phpMyAdmin, click on the root on the left hand side to expand.
- Find the WordPress's database to expand.
- In the tables, find "Wp-options".
- Click on the ‘Browse’ icon on the left in the top menu
- Find siteurl in the ‘option_name’ column, click the Pencil (Edit) icon and change
‘option_value’ from http://www.domain.com to http://www.subdomain.domain.com or http://www.domain.com/sub-directory (depending on whether you have setup sub-domain or not).
- Find home (in the same page or next page) in the ‘option_name’ column, click the Pencil (Edit) icon and change ‘option_value’ from http://www.domain.com to http://www.subdomain.domain.com or http://www.domain.com/sub-directory (depending on whether you have setup sub-domain or not).
Your moved WordPress sites should now be accessible using the new URL.
You can also learn more about moving a WordPress site here.