How To Migrate Your WordPress Website

You are here:
Estimated reading time: 1 min

1. Backup Everything

Before doing anything, back up:

  • WordPress files (themes, plugins, uploads)
  • Database

You can use plugins like UpdraftPlus and All-in-One WP Migration or do it manually via cPanel/phpMyAdmin.

2. Copy Files to the Main Domain

Option A: If both the subdomain and the main domain share the same hosting account:

  • Use FTP or File Manager (in cPanel).
  • Navigate to the subdomain directory (/public_html/sub or similar).
  • Copy all files to the root directory (/public_html).

Option B: Different servers or accounts:

  • Download all files from the subdomain.
  • Upload them to the root directory of the main domain.
Update wp-config.php (if needed)

Usually, no changes are needed if you’re using the same database.
But if you moved to a different server/database, update the following in wp-config.php

4. Update Site URL in the Database

You need to change the site URL and home URL from the subdomain to the main domain.

Option A: Use phpMyAdmin

  1. Open your database.
  2. Go to the wp_options table.
  3. Change the values of:
    • siteurl
    • home
      From: https://sub.example.comhttps://example.com

Option B: Use WP-CLI

Option C: Add temporarily in wp-config.php

If you can’t access the dashboard

5. Search and Replace URLs in Database

Update all internal links and media URLs pointing to sub.example.com.

Tools:

  • Plugin: Better Search Replace
    WP-CLI
  • 6. Fix Permalinks

    1. Log in to your WordPress dashboard at example.com/wp-admin.
    2. Go to Settings > Permalinks.
    3. Click Save Changes to regenerate .htaccess.

    7. Redirect Subdomain to Main Domain (Optional)To maintain SEO and users, redirect old subdomain URLs.

  • In the .htaccess of the subdomain folder
  •  Check and Test Everything

    • Visit https://example.com
    • Check links, images, admin panel
    • Test contact forms, plugins, and widgets

    Optional: Update Google Search Console

    • Add the main domain as a new property

    Submit a new sitemap

Was this article helpful?
Dislike 0

Author

Jephthah