Redirect Blog Subdomain to Main Domain: Step-by-Step
This guide shows you how to permanently redirect a blog subdomain (like blog.yourdomain.com) to your main domain (yourdomain.com) so visitors, search engines, and any existing links all land on the correct URL. You’ll need access to your domain’s DNS settings and your web hosting control panel (cPanel, Plesk, or similar). The process involves creating a redirect rule, usually via .htaccess on Apache servers or through your hosting provider’s redirect tool.
What You’ll Need
- Access to your domain registrar’s DNS settings (where you manage nameservers and DNS records).
- Access to your web hosting control panel (cPanel, Plesk, etc.) to edit files or use redirect tools.
- If your blog is on a separate platform (like WordPress.com, Tumblr, or Medium), you’ll need admin access to that platform to set up a redirect there.
- An FTP client (like FileZilla) or the file manager in your hosting panel, if you need to edit .htaccess manually.
Step-by-Step
- Back up your blog content. Before making any changes, ensure you have a full backup of your blog posts, images, and database. This protects you if something goes wrong.
- Create a subdomain (if it doesn’t exist). In your hosting control panel, go to the “Subdomains” section and create the subdomain (e.g., blog.yourdomain.com) pointing to a folder (e.g., public_html/blog). Even if you’re redirecting it, the subdomain must exist as a DNS record.
- Set up a 301 redirect via .htaccess (Apache servers). In the root folder of the subdomain (the folder you assigned to the subdomain), create or edit the .htaccess file. Add the following code:
RewriteEngine On RewriteCond %{HTTP_HOST} ^blog\.yourdomain\.com$ [NC] RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R=301,L]Replace yourdomain.com with your actual domain. This redirects all requests from the subdomain to the same path on your main domain (e.g., blog.yourdomain.com/post → yourdomain.com/post). If you want to redirect everything to the homepage, use
https://www.yourdomain.com/in the RewriteRule. - Alternatively, use a hosting redirect tool. In cPanel, go to “Redirects” under the “Domains” section. Choose the subdomain as the source, enter the destination URL (your main domain), select “Permanent (301)”, and click “Add”. This generates the .htaccess rule automatically.
- If your blog is on a separate platform (e.g., WordPress.com, Tumblr): In the platform’s settings, look for “Domain” or “Redirect” options. For WordPress.com, go to Settings → Writing and enable “Redirect blog subdomain to main domain” (if available). For Tumblr, go to Settings → Your blog → Redirect domain. Follow the platform’s instructions to set up the redirect.
- Update your main domain’s DNS (if needed). If your main domain is on a different hosting provider, ensure that the subdomain’s DNS record points to your hosting server. Usually, a wildcard or specific A record for the subdomain is already set. If not, add an A record for “blog” pointing to your server’s IP address.
- Test the redirect. Open a browser and visit blog.yourdomain.com. You should be redirected to your main domain. Check a few specific URLs (e.g., blog.yourdomain.com/old-post) to ensure they redirect to the corresponding page on the main domain.
- Update internal links. After the redirect works, go through your main site and any external content to replace links pointing to the old subdomain with the new URLs. This is important for SEO and user experience.
- Monitor for errors. Use Google Search Console to check for crawl errors and ensure the redirect is working correctly. Also, check your site’s traffic logs for any 404 errors.
Common Mistakes
- Using a 302 redirect instead of 301. A 302 is temporary and won’t pass SEO value. Always use 301 for permanent redirects.
- Redirecting to the wrong path. If you use a generic redirect that sends everything to the homepage, you lose the URL structure. Make sure to preserve the path ($1) in the redirect rule.
- Forgetting to update the subdomain’s DNS. If the subdomain doesn’t resolve to your server, the redirect won’t work.
- Editing the wrong .htaccess file. The .htaccess must be in the subdomain’s document root, not the main domain’s root. Double-check the folder path.
- Not testing with different URLs. Test not just the homepage but also deep links to ensure the redirect works for all paths.
Tips
- Use HTTPS. Ensure both the subdomain and main domain are using HTTPS to avoid mixed content issues. Use
https://in the redirect rule. - Preserve query strings. If your blog URLs have parameters, you may want to add
QSA(Query String Append) to the RewriteRule:RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R=301,L,QSA] - Set up a wildcard redirect for any subdomain. If you have multiple subdomains, you can use a wildcard:
RewriteCond %{HTTP_HOST} ^(.*)\.yourdomain\.com$ [NC]and then redirect to the same path on the main domain. - Use a redirect checker tool. After setting up, use online tools to verify the redirect status code (should be 301) and that it goes to the correct URL.
- Keep a backup of the .htaccess file. Before editing, download a copy so you can revert if needed.
Troubleshooting
If the redirect doesn’t work, follow these steps:
- Check the subdomain’s DNS. Use a tool like
dig blog.yourdomain.comor an online DNS checker to see if the subdomain resolves to your server’s IP. If not, add an A record. - Verify the .htaccess file is active. Ensure your server uses Apache and allows .htaccess overrides (AllowOverride All). Check with your host if you’re unsure.
- Test the redirect rule in isolation. Temporarily remove other rules in .htaccess to see if there’s a conflict. Also, ensure the file starts with
RewriteEngine On. - Check for typos. A missing dot or slash in the rule can break it. Copy the example and replace only the domain parts.
- Clear your browser cache. Sometimes the browser caches the old redirect. Try in incognito mode or use a different browser.
- If using a hosting redirect tool, ensure it’s enabled. Some hosts require you to click “Save” or “Add” after entering the details. Also, check that the tool doesn’t conflict with a manual .htaccess rule.
- If your blog is on a separate platform, check the platform’s documentation. Some platforms have specific requirements for domain mapping and redirects. For example, on WordPress.com, you may need to upgrade to a paid plan to use a custom domain and redirect.
Frequently Asked Questions
Will a 301 redirect hurt my SEO?
No, a 301 redirect is the recommended way to consolidate SEO. It tells search engines that the old URLs have permanently moved, and they will transfer most of the ranking signals to the new URLs.
Can I redirect a subdomain without a hosting account?
You need some form of web hosting to serve the redirect. If your subdomain is on a third-party service (like a blog platform), you can set up the redirect within that service’s settings. If you don’t have hosting, you can’t create a .htaccess file.
What if I want to redirect only certain pages, not the whole subdomain?
You can modify the RewriteRule to match specific paths. For example, to redirect only /blog/ to the main domain, use RewriteRule ^blog/(.*)$ https://www.yourdomain.com/$1 [R=301,L].
How long does it take for the redirect to take effect?
DNS changes can take up to 24-48 hours to propagate, but .htaccess changes take effect immediately. If you’ve just added the subdomain, wait for DNS to propagate before testing.
Can I redirect from HTTP to HTTPS as well?
Yes, you can combine both redirects. First redirect HTTP to HTTPS, then redirect the subdomain. Or use a single rule that includes the HTTPS protocol in the destination.
What if my main domain uses a different hosting provider?
You can still set up the subdomain on the blog’s hosting provider and redirect to the main domain. The redirect happens on the server where the subdomain is hosted, so it doesn’t matter where the main domain is hosted.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.