If your current WordPress site is infected with a virus, migrating to WebHostingPK with a clean WordPress installation is the best way to restore your website. This guide will show you how to migrate only essential files (wp-content, wp-config.php, and database) while installing a fresh version of WordPress.
Step 1: Backup Your Clean Files and Database
Before migration, backup only the necessary files from your old hosting to avoid transferring infected files.
Backup wp-content Folder
- Connect via FTP (FileZilla) to your current hosting.
- Download the wp-content folder (this contains your themes, plugins, and media uploads).
- Do not copy other files, as they may be infected.
Export the Database from phpMyAdmin
- Log in to phpMyAdmin on your current hosting.
- Click on your WordPress database in the left menu.
- Select the Export tab.
- Choose the Quick method and format as SQL.
- Click Go to download the SQL file.
Backup wp-config.php File
- Open File Manager in cPanel.
- Locate and download wp-config.php (this file contains database connection details).
- Do not migrate other files from the root folder.
Step 2: Set Up a New WordPress Installation on WebHostingPK
Option 1: Install WordPress Using Softaculous (Recommended)
- Log in to cPanel on WebHostingPK.
- Scroll to the Softaculous Apps Installer section.
- Click on WordPress and select Install Now.
- Enter your domain name and set an admin username and password.
- Click Install and wait for the setup to complete.
Option 2: Install WordPress Manually
- Download the latest WordPress version from wordpress.org.
- Go to File Manager in cPanel and navigate to public_html.
- Delete all files except for the wp-content and wp-config.php backups.
- Upload and extract the new WordPress zip file in public_html.
Step 3: Upload Your Clean Files
- Using File Manager or FTP, upload your wp-content folder to public_html.
- Replace the new wp-config.php file with the backup copy from the old website.
Step 4: Import the Database
- Open phpMyAdmin in WebHostingPK’s cPanel.
- Click on Databases > Create New Database.
- Name the database and click Create.
- Click the Import tab, select your SQL backup file, and click Go.
- Once uploaded, go to wp-config.php and update the database name, username, and password.
Step 5: Update Domain and DNS
- Log into your domain registrar (GoDaddy, Namecheap, Cloudflare, etc.).
- Update DNS nameservers to WebHostingPK’s servers (found in your hosting email).
- Wait 4-24 hours for DNS propagation.
Step 6: Final Checks and Security Enhancements
✅ Update Permalinks – Go to WordPress Admin > Settings > Permalinks > Save Changes.
✅ Scan for Malware – Install Wordfence or Sucuri Security plugins to scan for infections.
✅ Enable Free SSL – Activate SSL from WebHostingPK’s cPanel for security.
✅ Check Plugin & Theme Updates – Update outdated software to prevent vulnerabilities.
Conclusion
By migrating only essential files (wp-content, wp-config.php, and database) and installing a fresh WordPress copy, you can remove malware while keeping your site safe. If you need help, WebHostingPK offers free website migration services.