Skip to main content

Why can subdomains be accessed through the main domain URL?!?

Comments

5 comments

  • ffeingol

    Because that's the way that Apache works.  To the main domain that's just another folder that can be served up, just like any other folder.

    If you want to completely isolate them, you need to have the sub-domain/addon-domain above the public_html folder.  Not all hosts will allow this (it's a configuration option on the server that your host decides on).

    0
  • Hefin

    I'm using NGINX but I guess Apache is going to do the same.

    I own and manage the WHM/cPanel server for a range of client sites.  So if there is a way to change this behaviour in WHM options that would be great. 

    But looking at the domain documentation: https://docs.cpanel.net/cpanel/domains/domains/ it states Under the Create a New Domain:  'You cannot create a document root outside of the public_html/ directory'

    0
  • ffeingol

    If you have root access, go to tweak settings and the search for "Restrict document roots to public_html".  Sounds like yours is on the default "On".

    1
  • Hefin

    Sweet as a nut! Yeah the setting was on by default.  Turned it off now

    After switching it off the Domain options in the cPanel doesn't restricted to the Public_HTML, where the house icon is below used to say public_html before, but this is removed now 

    Many Thanks @ffeingol

    1
  • ffeingol

    No problem at all.  There are so many tweak settings, it's easy to miss things like this.

    2

Please sign in to leave a comment.