How to copy your WordPress site to a subdomain for secure testing


Looking to build a new website, update an old one, or try out new plugins? The best practice is to start by using a staging website. This provides a safe environment for testing and experimenting, and if something goes wrong, you don’t have to worry about your live website crashing or shutting down for a while.

The specific steps to take to create an intermediary website may differ depending on the type of website. In this article, you will learn how to easily copy your WordPress site to a subdomain for secure staging. Here are the steps to follow:

Step 1: create a subdomain

You will need a subdomain where you can host your new staging websites. Hope you already know what a subdomain is. Subdomains are free to create, and most hosting services allow you to create many. This makes building your middleman website in a subdomain a good solution.

To create a subdomain, go to cPanel and go to Areas > Subdomains.

Screenshot of the domains section in cPanel

In the resulting interface, enter the name you chose for your subdomain and click to create.

Step 2: Create and upload a copy of your website

Once you’ve created a subdomain, you now have an address for your intermediary website. The next step in creating an intermediate version of your website will be to clone your existing website. It’s easy to do using FTP. You will need to download and install an FTP client, and we recommend that you use FileZilla for this because it is free and open-source.


Screenshot of filezila installation

Once installed, you will need to connect your FTP client to your FTP server. To do this, you will need your FTP account details, and these are usually provided by your hosting provider when you sign up for a new web hosting account.

The required fields are host, username, password and port. You will see two panes in your FTP client. On the left are your computer folders and on the right are your website files.

Copy these files and save them to any folder on your computer.

You can also do this in cPanel. Move towards Files> File Manager> Public_html. In the upper right corner of the interface, click on settings. In the resulting pop-up, check Show hidden files.

Screenshot of cPanel settings to show hidden files

Select all of the folders that appear except cgi-bin, and click vsopie in the top menu, or right click on the selected files and select copy. In the pop-up window that appears, enter a name for the directory. This will be the name you chose for your subdomain.

Step 3: Export the database

The next step in cloning your WordPress website will be to copy your live website’s database to the intermediary website. The database is where all of the content and data for a WordPress website is stored. You will need to create a new database for your staging website before importing database content from your live website.

In cPanel, go to Databases> MySQL Databases. In the resulting interface, enter a name for your new website. It can be anything, for example, “test”.


Once done, head to phpMyAdmin> databases. Here you will export the old database and import the content into the new one with a few simple steps.

In the left panel, click on the old database then export. The file will then be downloaded to your computer.

To download it to your new database, simply click on the new database then import. Search and download the database from your computer.

Database export

Once done, the next step will be to change the database credentials in the wp-config.php to file.


In the wp-config.php file, find the line that says define (‘DB_NAME’, …..);. Just replace the database name with the new one here. Once done, you are almost ready.

The last step will be to change the URLs in the new database, to make sure they all point to the new website instead of the old one.

You will need to do this with a plugin. There are several plugins you can use to get the job done, however, we recommend WP Migrate Database.

Step 4: Edit URLs with WP Migrate DB

To get started, install and activate the plugin from the WordPress plugins directory. Once done, click on Tools in the left menu and select Migrate the database.


Click on Emigrate and scroll to the section titled Tools for this site.


To select Custom find and replace. This will open a drop-down interface with an option to Find and another for To replace.

In space for Find, enter the name of your old website preceded by two slashes like this: // In space for To replace, do the same with the URL of your new site.

That’s it! You should have a fully functional staging website to work with.

Two more ways to clone your website to a subdomain for staging

You don’t always need to use the manual method to clone your website to a subdomain for staging. In fact, there are several ways to create a staging website. Two of the easiest methods include using custom options provided by your hosting service or using a plugin.

Here is a brief overview of the two alternatives:

Alternative 1: create a staging website in cPanel

If your hosting service uses cPanel, you can set up an intermediary website with just a few clicks. To get started, first create a subdomain by following the steps outlined in step 1 above.

Once done, navigate to Software> WordPress Manager by Softaculous.

Click the drop-down icon next to your website name, then click staging, then enter the subdomain you created.

That’s it. If you’d rather not use this method or your hosting service doesn’t use cPanel, you can try using a WordPress plugin.

Alternative 2: use a WordPress plugin to create a staging website

There are several plugins that help in creating staging websites. We have already talked about it: Migrate DB. Migrate DB is a great solution for changing URLs, but to use its other features to build a staging website, you will need the premium version.

Alternatively, you can use one of the many free staging plugins such as Duplicator, WP Stagecoach, Ascending cloning, etc.

Get started with cloning your WordPress website

Building a staging website to build a website before going live, or to test for updates, new plugins, or any customization, is always a good idea. We’ve shown you how to do it manually, as well as how to leverage your cPanel to build an intermediary website. We have also mentioned some useful plugins for this.

If you are just starting to build your website, it might be a good practice to create it in a local development environment first, so that you don’t need to clone it afterwards.

Server house with written code

The 9 Best XAMPP Alternatives to Host Your Website Locally

Tired of using XAMPP? Try these local server management tools instead.

Read more

About the Author


Comments are closed.