I have cPanel Hosting with only 1 IP. I'm in the process of pointing all my TLDs to this server.

I have created Addon Domains and all the folders from which it creates are located in sub directories example1.com, example2.com in my root website /home/user/public_html/client/ but they can also be accessed from example1.maindomain.com. The thing that is worrying me is if Google indexes these subdomains.

What can I do to prevent this, would a rewrite rule like this be sufficient?

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example1\.com$ [NC]
RewriteRule ^(.*)$ http://www.example1.com/$1 [L,R=301]

Or is there a better way?

2 Answers 2


If you don't use cPanel, the correct way to do this is to put each of domain into is very own directory. Apache is not really designed to handle overlapping domains the way that cPanel sets things up. This seems to be a limitation of cPanel.

One technique that should work is to treat all of your domains as "add on domains." Set your main domain name in cPanel to a subdomain that doesn't actually have a DNS entry. Something like allmysites.example.com. Then Google can't actually crawl the main directory at all. Your directory structure would then look like:

  • allmysites (serves allmysites.example.com which isn't accessible through DNS)
    • site1 (serves site1.example.com)
    • site2 (serves site2.example.com)
    • site3 (serves site3.example.com)
  • Just to make this clear: Subdomain 'public_html/clients/' 'client.mydomain.com' - serves site1 (site1.mydomain.com) 'public_html/clients/site1.com/' Should I delete all the DNS records for this main subdomain?
    – tom
    Dec 15, 2013 at 17:36
  • You shouldn't delete DNS records for anything. All your DNS records should still point to your server. You should just configure cPanel to serve nthoaesuoaeuaou.example.com from public_html and create a add on domain for your main site. Dec 15, 2013 at 18:10
  • I've created a subdomain which stores all my addon domains will that be ok? Not able to make a 'AddOn' for my main site, conflicts in DNS or something.
    – tom
    Dec 15, 2013 at 18:32

Google, like all decent web crawlers, honors Robots Exclusion Standard (robots.txt). If there really is a limitation not to use separate folders for every domain and you don't want to treat all domains as cPanel "Add on domains", you could prevent the indexing of these folders (but not access to the folders) by adding /home/user/public_html/client/robots.txt:

User-agent: *
Disallow: /site1-directory/
Disallow: /site2-directory/

As the additional domains have different roots, this robots.txt will only affect the main site.

  • However, this doesn't prevent the subdomains from being crawled/indexed - which seems to be the main concern raised in the question. For the subdomains you can't use robots.txt in this way since it's the same document root as the Addon domain.
    – DocRoot
    Oct 20, 2019 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.