Redirect rule | subdomain to main domain | htaccess

If you have a subdomain and want to redirect it to your main domain, then this post provides the redirect rule that you have to add in .htaccess file in sub-domain’s root directory.

Also read: Serve static content like images from subdomain to increase website page speed

For example, if your subdomain is img.example.com and main domain is example.com, then the htaccess redirect rule is

  1. Replace example.com with your domain name
  2. Replace img with your subdomain name
  3. Create a empty .htaccess file at root directory of sub-domain
  4. Copy the above updated redirect rule to htaccess file and upload
  5. Check whether the subdomain pages redirect to main domain

So, if you enter img.example.com/page1.html, it redirects to https://www.example.com/page1.html

About the Author

SRINI S

A passionate blogger. Love to share solutions and best practices on wordpress hosting, issues and fixes, excel VBA macros and other apps

Leave a Reply

Your email address will not be published. Required fields are marked *