I have 2 website which is hosted in a shared hosting.
1st website
example.com hosted in a root directory as /public_html/

2nd website
example2.com hosted in a sub-directory directory as /public_html/example_2/

I have this in example.com/robots.txt

User-agent: *
Disallow: /example_2/
sitemap: https://www.example.com/sitemap.xml

I have this in example2.com/robots.txt

User-agent: *
sitemap: https://www.example2.com/sitemap.xml

I want google to index both the website separately but do not mixed each another, what I know is if a website is submitted then google scrap whole directory, except the Disallow one; So if I Disallow: /example_2/ will it effect example2.com. If so then what is the best way to write robots.txt for 2 website.

I'll be very great-full if some one can show me the right path.

  • You are seriously over-thinking this. ;-) The directory for example2.com is /public_html/example_2/. This is where you put your robots.txt for this site. Nothing more needs to be done. Why? because /public_html/example_2/ and by extension example_2/ is a local directory and not a directory on your site. It is not seen by the web. Cheers!!
    – closetnoc
    Feb 16, 2017 at 4:01
  • ok @closetnoc, so my both robots.txt are good and I dont have to do any thing at this point of time right? and yes as it is not my cup of coffee so I thik 5 times before adding a single drop of sugar. Feb 16, 2017 at 4:44
  • I like how you put it better! When it is not my cup of coffee, I put salt in it... but that is not what you meant is it? [humor] You should be fine. Cheers!!
    – closetnoc
    Feb 16, 2017 at 4:48
  • he he, thanks. So you can put this as an answer then I can accept it, and let other developer like me to know how much salt not to add ;) Feb 16, 2017 at 4:53

1 Answer 1


It appears that for cPanel, and perhaps others, certainly to be expected with web hosts these days, while creating a second or third web site or even a sub-domain, cPanel in order to save on setting file permissions, creates any additional site within the web space of the first site created. This may be a result of the old Apache schema using httpd.conf and compatibility. Who knows? The result is that there is confusion and potential problems that can arise.

/public_html/ is the original sites web space for example.com

/public_html/example_2/ is the second site for example2.com

For example.com, the directory directive within the configuration file points to /public_html/ and for example2.com, the directory directive within the configuration file points to /public_html/example_2/.

These are local directories on your file system and not how things are seen from the web.

What is put into /public_html/ such as index.html will be seen as example.com/index.html and what is put into /public_html/example_2/ such as index.html will be seen as example2.com/index.html.

The same will be true for robots.txt and any .htaccess file you choose to create. Example.com robots.txt would go into /public_html/ and example2.com robots.txt would go into /public_html/example_2/.

The drawback to this configuration is that example.com/example_2/index.html will show the sites home page for example2.com/index.html. This is generally not a problem. Just something to remember.

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.