Disable access from subdomains

cicklow

Registered
Jun 7, 2018
4
0
1
-
cPanel Access Level
Root Administrator
Hello, I have as main domain (it is an example) domain.com, when adding a new domain a subdomain is created (example) name.dominio.com (for name.com), but if I access name.dominio.com it shows me the name.com website.

How do I prevent the subdomains of the main cpanel domain from showing web sites?

From cPanel -> domains-> zone editor-> domain.com I can see all the subdomains of the created domains. If I eliminate them, will it bring me a problem? or how can I block access (or visualization) of the subdomains.
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,295
1,255
313
Houston
Hi @cicklow

When you create an addon domain the subdomain is automatically created, this is what allows you to create an addon domain. The addon domain is ultimately just an alias for the subdomain and shouldn't cause an issue.
 

cicklow

Registered
Jun 7, 2018
4
0
1
-
cPanel Access Level
Root Administrator
@cPanelLauren Hi, thank you for you answer. but how do I block access to the subdomain? so avoid having my websites viewed from name.primarydomain.com or primarydomain.com/user/folder
only access from name.com
 

cicklow

Registered
Jun 7, 2018
4
0
1
-
cPanel Access Level
Root Administrator
Hello, that does not solve my problem. I'll try to explain myself better.
I have as main domain in cpanel: example.com, when I add a new domain, a subdomain is created in example.com, example if I add the domain example.net, the subdomain is created: example.example.com.

My problem is that if you access example.example.com you are viewing the site example.net.

Now my question is: how do I block access to example.example.com and leave true access to example.com

I know I can do it with .htaccess, but I have many domains. And I have to create a .htaccess for each domain, redirecting the subdomain to the original domain.
 
Last edited by a moderator:

Infopro

Well-Known Member
May 20, 2003
17,113
511
613
Pennsylvania
cPanel Access Level
Root Administrator
Twitter
Hello, that does not solve my problem.
If you add the new domain, outside public_html, I do think you'll achieve what you seek.

when I add a new domain, a subdomain is created in example.com
Unless you create it outside public_html.


From the cPanel documentation:
Tweak Settings - Domains - Version 68 Documentation - cPanel Documentation

Restrict document roots to public_html

This setting prevents the creation of addon domains and subdomains outside of a cPanel user's primary domain's document root (the public_html directory within the user's /home directory).

For example, if you enable this setting and then create the example.com addon domain, the system creates the /home/username/public_html/example.com directory rather than the /home/username/example.com directory.

This setting defaults to On.
 

Infopro

Well-Known Member
May 20, 2003
17,113
511
613
Pennsylvania
cPanel Access Level
Root Administrator
Twitter
If your main domain is, example.com, it is, public_html of course. If you want to add an addon domain, example.net, and you change the doc root when creating example.net to be /, then it will not be accessible from example.example.com

You cannot view the addon domain as a subdomain, if you change the doc root of the addon domain to be, /, on creation.

HTH!