Moving a WordPress site from a subdomain to the main domain isn’t uncommon. Many website owners start with a development or staging site located at a subdomain (like dev.example.com or staging.example.com) and later decide to make it live on the main domain (like example.com). Whether you’re ready to launch or just need a more streamlined URL, transferring your WordPress site safely to the main domain can seem daunting—but it doesn’t have to be.
Why Move WordPress from a Subdomain to the Main Domain?
Using a subdomain is practical during development, allowing you to build or redesign the website without affecting the live site. However, once the site is ready for production, you’ll likely want to move it to the main domain for several reasons:
- SEO Benefits: Search engines treat subdomains as separate sites, which can split your SEO efforts.
- Brand Consistency: Displaying your main domain increases trust and brand recognition.
- Improved Analytics: It’s easier to manage and interpret analytics from a single domain.
Preparations Before the Move
Before moving your WordPress site, it’s crucial to prepare properly. Follow these initial steps to ensure a smooth transition:
- Backup Your Entire Site: Use a plugin like UpdraftPlus or BackupBuddy to back up both the database and files.
- Update Your Hosting and DNS: Ensure your hosting environment is ready and your main domain points to the correct server directory.
- Disable Caching: Turn off any caching plugins temporarily to avoid conflicts after the move.
Step-by-Step Guide to Move WordPress to the Main Domain
Step 1: Copy Files from Subdomain to Main Domain
Use an FTP client like FileZilla or the File Manager in cPanel to copy all files from the subdomain folder (usually /public_html/subdomain) to the main domain root folder (usually /public_html).

Make sure that you do not overwrite any important files in the root directory, especially if there’s already a site running.
Step 2: Export and Import Your Database
You’ll need to use phpMyAdmin or a plugin to export your subdomain site’s database:
- Open phpMyAdmin in your hosting cPanel.
- Select your subdomain’s database and click Export.
- Go to the main domain’s database and click Import to upload the SQL file.
If you’re using the same database for both subdomain and main domain, skip the export/import and only update site URLs.
Step 3: Update wp-config.php
In the root directory, open wp-config.php and ensure the database credentials point to the correct DB if you’re using a separate one for the main domain.
Step 4: Change Site URL and Home URL
Update the URL in your WordPress settings from the database:
- Open phpMyAdmin and go to your WordPress database.
- Locate the table wp_options (prefix may differ).
- Change the siteurl and home values from http://sub.example.com to http://example.com.
Step 5: Update URLs in Posts, Pages, and Media
All internal URLs will still point to the subdomain, which can cause broken links. Use a plugin like Better Search Replace or Velvet Blues Update URLs to find and replace all instances of the subdomain URL throughout your site content and database.

Step 6: Set Up Redirects (If Needed)
Set up 301 redirects from the subdomain to the main domain so users and search engines are redirected automatically:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^sub.example.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] </IfModule>
Place this code in the .htaccess file in your subdomain directory.
Step 7: Clear Cache and Permalinks
After the move, log in to WordPress via example.com/wp-admin and go to:
- Settings → Permalinks: Just click “Save Changes” to flush permalinks.
- Clear any plugin or server-side cache manually.
Step 8: Submit to Google Search Console
In Google Search Console, add your main domain as a new property if not already added. Then submit a new sitemap and use the Change of Address tool if applicable to help search engines recognize the domain shift.
Testing Your Site After the Migration
Once the move is complete, it’s essential to thoroughly test your website to catch any hidden issues:
- Ensure all URLs now lead to the main domain.
- Check forms, login functions, and shopping carts if applicable.
- Use a broken link checker plugin to identify and fix any dead links.

Common Problems and How to Fix Them
- White Screen of Death: Enable WP_DEBUG in wp-config.php to pinpoint the error.
- Broken Layout or Missing Styles: Make sure URLs are updated for CSS and JS files.
- Login Issues: Clear browser cache or reset your WordPress login URL using functions.php.
Conclusion
Migrating WordPress from a subdomain to the main domain can be simple when done step by step. Always back up your site before making major changes and take your time with each step. With correct preparation and attention to detail, you can preserve your SEO, avoid broken links, and ensure a smooth transition for both users and search engines.
FAQ: Moving WordPress from Subdomain to Main Domain
- Q: Do I lose SEO when moving from subdomain to main domain?
A: You can retain most of your SEO by setting up 301 redirects properly and notifying Google through Search Console. - Q: Is it better to use a plugin or do the migration manually?
A: Manual gives you complete control, but plugins like Duplicator or All-in-One WP Migration can simplify the process for beginners. - Q: What happens to the subdomain after migrating?
A: You can either delete it or keep it, but you should redirect it to the main domain to avoid duplicate content issues. - Q: Can I use the same database for both domains?
A: Yes, as long as the table prefixes remain consistent and there are no conflicts between installations. - Q: How soon will Google reflect the domain change?
A: It can take a few days to a few weeks. Consistently updating sitemaps, using redirects, and submitting through Google Search Console can speed up the process.