Duplicating a WordPress site to a subdomain allows you to test changes, create a staging area, or launch a new version of your website without affecting the live version. Here's how to do it:
1. Create a Subdomain
- Log in to your cPanel: Access your hosting control panel.
- Navigate to the Domains section: Locate the domain management area.
- Create a subdomain: Choose an appropriate name for your subdomain, such as "staging" or "test."
- Point the subdomain to your website's root directory: This ensures the subdomain points to the same location as your main website.
2. Back Up Your Existing Website
- Use a backup plugin: Install and use a reliable WordPress backup plugin, such as UpdraftPlus or BackupBuddy.
- Create a manual backup: Alternatively, download the complete files and database of your website.
3. Install WordPress on the Subdomain
- Navigate to the subdomain's directory: Access the folder where the subdomain's files will be stored.
- Upload the WordPress files: Transfer the downloaded WordPress files to this directory.
- Create a new database: In your cPanel, create a new database for your subdomain.
- Import the database: Use phpMyAdmin to import the backed-up database to the newly created database.
- Update WordPress configuration: In the
wp-config.php
file, adjust the database details to match the new database information.
4. Configure Your Subdomain
- Login to your WordPress dashboard: Access the newly installed WordPress site.
- Install necessary plugins: Reinstall any required plugins for your website.
- Import theme and content: Import the theme and content from the backup you made.
- Customize and test: Make any desired changes and test your subdomain thoroughly before making it public.
5. Redirect Subdomain Traffic
- Add a redirect rule: In your cPanel, create a redirect rule to point the subdomain to the live website's URL. This ensures users are directed to the correct site.
Note: This process may vary slightly depending on your hosting provider and cPanel version. Consult your hosting provider's documentation for specific instructions.