Businesses might switch a website from a subdomain (sub-domain.domain.com) to the main domain to strengthen their presence online. Proper site switching ensures no changes to traffic and user experience while ensuring more visibility after the migration.
Check out this guide for details on migrating your site from a subdomain to the central domain. Follow the no-BS migration process to switch your subdomain without unnecessary steps.
Key Takeaways
- Prepare your data backups and verify hosting settings before switching your site from the sub-domain to the main domain.
- Update configuration files, internal URLs, and 301 redirects to preserve the site’s SEO value.
- Perform thorough testing and monitor vital website metrics after migration to assess results.

1. Prepare for Migration
A few preliminary steps are essential before switching your site. These steps minimize risks while easing the transition process. Common pre-migration steps usually include:
Data backup
Sub-domain backup
Create a complete backup of your site’s files and database from the sub-domain. You can use cPanel’s backup function or another plugin on a CMS like WordPress.
Main domain backup
Back up files and databases for an existing website on the main domain. You do not need to take this step if no data exists on the main site domain, but backing up files on the main domain is a precaution if you ever need to revert changes later.
Hosting configuration
Add main domain
Make sure your primary domain is configured on the hosting account. You can verify this using the ‘Websites’ section on your cPanel dashboard. The domain should be a root folder to ensure your site is ready for migration.
Confirm disk space
Next, you must confirm that your hosting plan has enough space and resources to accommodate the files added from the subdomain.
Record URLs and settings
List sub-domain URLs
You must keep a list of sub-domain page URLs. This record will help you easily set up redirects and update internal links.
Record database settings
Take note of the sub-domain’s database login credentials (name, user login, and password). These details are necessary if you ever need to transfer or duplicate the database.
2. Migrate Files
You must move website files from the sub-domain’s directory to the main domain’s path. Compatible software with File Transfer Protocol (FTP) functionality, like cPanel’s File Manager, can help you complete this task. Follow these steps to migrate files without errors successfully:
Step 1: Access File Manager on cPanel
- Log in to your cPanel account using your login credentials.
- Next, click ‘File Manager’ to show your site’s directories.

Step 2: Locate sub-domain files
- Scroll to your sub-domain’s folder (usually called ‘sub-domain.domain.com’).
- Locate and open the ‘public_html’ folder in the sub-domain’s directory. The folder contains vital sub-domain files.
Step 3: Copy files to the leading domain directory
- Select every file and folder within the public_html directory.
- Click the ‘Copy’ option in the File Manager.
- Set the destination to the main domain’s root directory (usually public_html or a domain.com folder). Ensure the destination folder is empty to avoid errors.
- Wait for all files to copy and confirm that the process is complete.

3. Migrate Database
You may have to duplicate or move the entire database and update the site configuration to link to its primary domain. This may be necessary if your site uses a database, as with WordPress websites. Two methods may apply in such a scenario:
Option 1: Use existing database
You may retain the sub-domain’s database if it stays active after migration. Edit the configuration file to reflect the site’s new URL. Ensure the existing sub-domain database credentials do not change. Then you can update the site URL within CMS settings to reference the main domain’s address.
Option 2: Duplicate database
- Use phpMyAdmin (on cPanel) to export the sub-domain’s database as an SQL file.
- Go to the ‘Databases’ section and create a new database for the primary domain through cPanel.
- Open phpMyAdmin for the new database and import the SQL file exported from the sub-domain.
- Edit your site’s configuration file (wp-config.php for WordPress websites) in the main domain’s directory. Update the database credentials (name, user, and password) to match new settings.
- Load the site on the main domain to confirm the database’s functionality.
4. Update Website Configuration and URL
Updating internal references is essential to avoid broken link issues while maintaining your site’s functions. After transferring relevant files and databases to migrate to the main domain, you must perform these updates.
Modify configuration files
Edit site URL
Change the site URL setting to the main domain through your CMS. You can do this through your admin dashboard on a CMS like WordPress or in the config file.
Search and replace
Use a search-and-replace tool or plugin to update references from the sub-domain to the main domain within the database. This step is helpful for internal links and media.

Update hardcoded links
Examine theme scripts and files
You can manually check JavaScript or CSS files for hardcoded references to the sub-domain. Update these to reference the main domain.
Review custom code
Verify if URLs are correctly adjusted, and if any custom codes exist within the database.
5. Insert 301 Redirects
You must adopt correct redirection to transfer SEO value from the sub-domain to the main domain. This practice ensures visitors do not encounter broken links while gaining access to the same experience the sub-domain provides.
You can create 301 redirects using the .htaccess file in the main domain’s directory. Create and open an .htaccess file on the leading domain root directory if it already doesn’t exist. Add these lines at the beginning of the .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
Save the .htaccess file and confirm your changes are successful.
6. DNS and Hosting Settings
Depending on your hosting, DNS settings may need to be updated to reflect the migration. These steps ensure DNS and hosting settings align with your website migration.
Update DNS records
- Log in to your hosting provider’s domain registrar or DNS management panel.
- Update records that point to the sub-domain to reference the main domain’s server or IP address.
- Wait for 36 to 48 hours for DNS changes to take effect.
Harmonize hosting accounts
If the sub-domain and main domain were hosted separately, consolidate them under one account. To reduce costs, disable redundant hosting accounts or cancel plans on unused hosting.
7. Update Analytics Tools and Settings
You must update all linked tools and settings to maintain your search engine ranking and assess overall site performance quickly. Three (3) vital steps can help achieve this:
Revise XML sitemaps
- Use your CMS or an online tool to generate a new XML sitemap that includes only the primary domain’s URLs.
- Next, log in to Google Search Console and Bing Webmaster Tools. Submit the new sitemap to inform search engines of the changes.

Update search console
- Remove or deprecate the subdomain property in Google Search Console.
- If not already done, add and verify the main domain as a new property.
- Ensure that any analytics tracking codes are implemented on the main domain’s pages.
FAQs
What precautions should I take before starting the migration?
Before migrating your sub-domain to the main domain, you must thoroughly back up databases and files. Also, you need to verify that the main domain’s configuration is linked correctly to your hosting account.
Why should I migrate my website from a subdomain to the main domain?
You should migrate your site to simplify management while centralising SEO efforts and a consistent brand.
How do 301 redirects help during migration?
301 redirects transfer link equity from the subdomain to the main domain. This ensures visitors and search engines will automatically be redirected to the new URL.
How do I update internal links after moving the files?
Use a database search-and-replace feature or CMS plugin to update URLs from the sub-domain to the main domain. Next, manually check for hard-coded links in theme and script files.
How long does DNS propagation take after updating records?
Changes to the Domain Name Server (DNS) usually take between 36 and 48 hours for universal propagation.
What should I do if some pages do not load correctly after migration?
Check configuration files and verify that all file paths are up-to-date. Also, review the .htaccess file for redirect rules and confirm that DNS records propagate correctly.
Conclusion
Migrating a site from the sub-domain to the main domain requires careful planning and accurate execution. The steps outlined above can ensure a smooth transition without losing data. Proper migration also retains your site’s functionality and search engine ranking.
Take advantage of these steps to ensure your site performs as expected post-migration. It becomes easier to improve your site’s visibility potential and centralise your content under a unified domain.
If you found this helpful guide, consider checking out some of our other educational content or sharing it with a friend who might benefit from it!
