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

  1. Connect via FTP (FileZilla) to your current hosting.
  2. Download the wp-content folder (this contains your themes, plugins, and media uploads).
  3. Do not copy other files, as they may be infected.

Export the Database from phpMyAdmin

  1. Log in to phpMyAdmin on your current hosting.
  2. Click on your WordPress database in the left menu.
  3. Select the Export tab.
  4. Choose the Quick method and format as SQL.
  5. Click Go to download the SQL file.

Backup wp-config.php File

  1. Open File Manager in cPanel.
  2. Locate and download wp-config.php (this file contains database connection details).
  3. Do not migrate other files from the root folder.

Step 2: Set Up a New WordPress Installation on WebHostingPK

  1. Log in to cPanel on WebHostingPK.
  2. Scroll to the Softaculous Apps Installer section.
  3. Click on WordPress and select Install Now.
  4. Enter your domain name and set an admin username and password.
  5. Click Install and wait for the setup to complete.

Option 2: Install WordPress Manually

  1. Download the latest WordPress version from wordpress.org.
  2. Go to File Manager in cPanel and navigate to public_html.
  3. Delete all files except for the wp-content and wp-config.php backups.
  4. Upload and extract the new WordPress zip file in public_html.

Step 3: Upload Your Clean Files

  1. Using File Manager or FTP, upload your wp-content folder to public_html.
  2. Replace the new wp-config.php file with the backup copy from the old website.

Step 4: Import the Database

  1. Open phpMyAdmin in WebHostingPK’s cPanel.
  2. Click on Databases > Create New Database.
  3. Name the database and click Create.
  4. Click the Import tab, select your SQL backup file, and click Go.
  5. Once uploaded, go to wp-config.php and update the database name, username, and password.

Step 5: Update Domain and DNS

  1. Log into your domain registrar (GoDaddy, Namecheap, Cloudflare, etc.).
  2. Update DNS nameservers to WebHostingPK’s servers (found in your hosting email).
  3. 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.

Leave A Comment

more similar articles