How to copy my WordPress site into a sub-domain?
There are few steps than need to be followed in order to copy a WordPress site. All of the actions can be done through cPanel.
– Create the desired sub-domain (in the tutorial, we are using new.cabbagecorp.net). When you are creating it, it will show you the path (document root) to its folder. You will need it later. In this case, we have /public_html/new
– Go into the public_html folder and use the “Select all” and “Copy” options to copy your WordPress Files from your current directory to the document root directory created for your sub-domain. In the pop-up widow, you can put in the root directory of the sub-domain. Make sure to copy the .htaccess file. This file needs to reside in the same location where you have copied your WordPress files or at the root of the new location. The .htaccess file may contain important references to your current WordPress installation.
****Important! When selecting all your WordPress Files, make sure the folders for the subdomains/addon domains, or any other non WordPress folders, are not selected. After selecting all, hold the Ctrl key on the keyboard and click the folders that are not being moved so the are not highlighted blue before copying the files.
– Export your current database through cPanel > phpMyAdmin. If you are not sure which database to export, locate the wp-confic.php file in the File Manager and use the “View” option. In the file is defined the database used by the application. (More on the export – https://www.tmdhosting.com/tutorials/video/phpmyadmin/phpma-export.html)
– Import your Database to the new database you created. (https://www.tmdhosting.com/tutorials/video/phpmyadmin/phpma-import.html)
– Configure the new WordPress wp-config.php file for the test site. This needs to be done or the sub-domain site will use the main WordPress site database. Use the “Edit” option in the File Manager. Make sure the changed file is the one located in the folder of the sub-domain, not the main one
– In phpMyAdmin, change the site URL for the test site – The site URL is stored in the WordPress database (Look for table Options), in order for the site to load as a test site, the site URL will need to be changed to the sub domain URL:
– Correct image links – Lastly, ensure that image links in your pages and posts are also changed. These are in the database and not connected to the site URL so they will need to be changed separately. Search the database for the original URL and replace it in the results (https://www.tmdhosting.com/tutorials/video/phpmyadmin/phpma-search.html).
This is it. You now have a working copy of the site in a sub-domain.