How to copy a site to a subdomain for testing
A subdomain copy gives you a real, public URL to test changes on without touching the live site at all.
A subdomain copy — something like staging.yourdomain.com — gives you a real, reachable web address to test on without going anywhere near the live site. It is useful for trying a big change, testing a migration's file and database copy before committing to it, or letting someone else review work before it goes live, and it is a different tool from the hosts file trick used to preview a completely different server.
Setting it up
- Create the subdomain in your control panel, which gives it its own folder on the server.
- Copy the live site's files into that folder.
- Create a separate database for the copy — never point a test copy at the live database, since anything it writes will affect the real site.
- Import an export of the live database into the new one.
- Update the copy's configuration file with the new database name, user and password, so it points at its own database rather than the live one.
Block it from search engines
A subdomain copy is a real, public URL, which means search engines can find and index it if nothing stops them — and a duplicate of your entire site sitting at a different address is not something you want turning up in search results. Add a robots.txt file to the subdomain that disallows everything, and consider password-protecting the folder as well if the content is sensitive or unfinished:
User-agent: *
Disallow: /
Test freely, then decide what to do with it
Because the subdomain copy has its own database, changes made there — testing a plugin, trying a new theme, checking how an update behaves — have no effect on the live site whatsoever. This is the whole point: it is a safe place to break things.
What you do afterwards depends on why you made the copy:
- Testing a migration's file and database copy — once satisfied it works, you would typically move on to testing directly on the destination server via a hosts file entry rather than keeping a permanent subdomain copy. See previewing a site with your hosts file for that step.
- Testing a change before applying it to the live site — once confirmed, you would repeat the change on the live site directly, or, for a database change, export the subdomain's database and import it over the live one.
- Keeping a permanent staging area — some sites keep a subdomain copy running long-term for ongoing testing before changes reach production, in which case leave it in place but keep the
robots.txtblock and password protection permanently too.
An old test subdomain, left live and forgotten, is a duplicate of your site sitting on the internet with nobody checking it for security updates. If you only needed it temporarily, remove it once you are done rather than leaving it running indefinitely.
For moving a site to entirely new hosting rather than testing on a subdomain of the same account, our full migration guide covers the process end to end, and the service is included free with our hosting plans — get in touch if you would like it done for you.
Related reading
One edit on your own computer lets you load the new server privately while every other visitor keeps seeing the old one.
How to test a migrated site before going liveThe whole point of testing before DNS switches is that mistakes are free to find and free to fix while nobody else can see them.
How to migrate just the databaseExport, create an empty database on the new server, import, then point the application at it — the files do not need to move at all.
How to host a second website on one accountHow one hosting account can run several genuinely separate websites, each with its own folder, domain, and DNS pointing.