Loading...

Knowledge Base
 Up to 70% off  on  WordPress  hosting for WordPress Websites and Stores!

How to Disable Subdomain Access for Addon Domains Using .htaccess

All addon domains must be associated with a subdomain. For more information about addon domains and subdomains, visit the article: What Is the Difference Between Addon Domain, Parked Domain & Subdomain? Learn how to disable subdomain access for addon domains using .htaccess.



Why Disable Addon Domain or Subdomain Access?

An addon domain is an independent domain name that enables you to launch a website. It operates differently than your main domain in terms of how it is added to Apache's configuration file. For example, if your main domain name is example.com and you add test.com as an addon domain, Apache will generate a vhost for test.example.com.

To be recognized as a fully qualified domain name, Apache will treat test.com as an alias to test.example.com, allowing visitors to view the content of the subdomain while typing the actual domain in their browser. Regrettably, the subdomain is highly likely to be accessible along with the domain you added as an addon, which may result in Google indexing the content twice under different URLs, potentially harming your site's rankings.

One of the main benefits of disabling addon domain or subdomain access is for SEO purposes. You can restrict addon domain or subdomain access using .htaccess to avoid this.

How to Disable Addon Domain or Subdomain Access

Below is a step-by-step guide to block an addon domain or subdomain with .htaccess:

  1. Access your .htaccess file to edit it. For instructions on editing your .htaccess file, see .htaccess Tutorial.
  2. Add the .htaccess code below, which provides a thorough means of making the addon domain folders and their contents invisible through the main domain by forcing a 404 Not Found error. This will work both for web browsers and search engines.
        RewriteEngine On
        RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ [NC]
        RewriteCond %{REQUEST_URI} ^/addonfolder/(.*)$
        RewriteRule ^(.*)$ - [L,R=404]
    The example rewrite rules will force 'http://www.domain.com/addonfolder/' and any of its contents to report the 404 Not Found error. Be sure to replace the 'domain.com' in the example with your hosting account's main domain address and 'addonfolder' with the name of the folder for your addon domain.
  3. This can also be applied to multiple addon domain folders through the use of the [OR] option as in the following example in which three addon folders are being reported as 404 Not Found when accessed through the main domain:
        RewriteEngine On
        RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ [NC]
        RewriteCond %{REQUEST_URI} ^/addon1/(.*)$ [OR]
        RewriteCond %{REQUEST_URI} ^/addon2/(.*)$ [OR]
        RewriteCond %{REQUEST_URI} ^/addon3/(.*)$
        RewriteRule ^(.*)$ - [L,R=404]

Summary

Understand the potential issues of having addon domains associated with subdomains and how they can harm your website's rankings. To avoid this issue, it is recommended to disable subdomain access for addon domains using .htaccess. The guide has steps to block addon domain or subdomain access using .htaccess to avoid any negative impact on your site's SEO.

If you need further assistance, feel free to contact us via Chat or Phone:

  • Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
  • Phone Support -
    • US: 888-401-4678
    • International: +1 801-765-9400

You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.

Did you find this article helpful?

 
* Your feedback is too short

Loading...