Sub-domain, add-on domain oddities

meeven

Well-Known Member
May 8, 2007
132
2
168
Just trying to sort out/understand a few issues relating to sub-domains and add-on domains:
  • Is there a way to prevent a sub-domain http://[B]sub[/B].example.com from also being accessible at its internally redirected path http://example.com/[B]sub[/B] ?
  • Why does cPanel create an add-on domain as a sub-domain of the primary domain? That is, if I add http://[B]example2.com[/B] as an add-on domain for example.com, it's actually set up as http://[B]example2[/B].example.com
  • If I delete the sub-domain entry above for the add-on domain in the cPanel sub-domains section, will the add-on domain still work?
  • Is there a way to ensure that an add-on domain's (http://example2.com) content is NOT accessible at its sub-domain (http://example2.example.com)?
  • Is it possible to create a sub-domain for an add-on domain? Techinically, this would be http://[B]sub.example2[/B].example.com. The sub-domain entry form defaults to adding the sub-domain paths even for an add-on domain as public_html/sub instead of public_html/example2.com/sub. When I go ahead and choose the latter path, I don't get any cPanel errors, but I just wonder if this will behave well if any content was actually put on the sub-domain of the add-on domain. I mean, will there be any problems with links, .htaccess files etc?
I will be very thankful indeed for any assistance about these issues/questions.
 
Last edited:

JPC-Stefan

Member
Oct 29, 2008
23
0
51
Hi

May be the following answers help you regarding sub-domain and add-on domain issues.

Is there a way to prevent a sub-domain http://sub.example.com from also being accessible at its internally redirected path http://example.com/sub ?
You can disable the access of subdomains URL like "http://example.com/sub" by redirecting it to either "http://sub.example.com" or to any other error page.

Why does cPanel create an add-on domain as a sub-domain of the primary domain? That is, if I add http://example2.com as an add-on domain for example.com, it's actually set up as http://example2.example.com
cPanel handle Add-on domains in this way. A add-on domain is equivalent to subdomain + Parked domain.

If I delete the sub-domain entry above for the add-on domain in the cPanel sub-domains section, will the add-on domain still work?
Sub-domain cannot be deleted having add-on domain related to it. First you have to remove add-on domain and then sub-domain.

Is there a way to ensure that an add-on domain's (http://example2.com) content is NOT accessible at its sub-domain (http://example2.example.com)?
Again this can be done using redirects.

Is it possible to create a sub-domain for an add-on domain? Techinically, this would be http://sub.example2.example.com. The sub-domain entry form defaults to adding the sub-domain paths even for an add-on domain as public_html/sub instead of public_html/example2.com/sub. When I go ahead and choose the latter path, I don't get any cPanel errors, but I just wonder if this will behave well if any content was actually put on the sub-domain of the add-on domain. I mean, will there be any problems with links, .htaccess files etc?
A subdomain for add-on domain can be created and you can set the path of this sub-domain to either "public_html/sub" or "public_html/example2.com/sub" and there will be no problem in both cases. However if example2.com is your add-on domain and your are creating sub-domain sub.example2.com, then it will be only accessible by "sub.example2.com" and not from "sub.example2.example.com"
 

meeven

Well-Known Member
May 8, 2007
132
2
168
Thanks for your answers.

You can disable the access of subdomains URL like "http://example.com/sub" by redirecting it to either "http://sub.example.com" or to any other error page.
This doesn't work. Instead, you get the following message:
You cannot redirect sub to http://sub.example.com as will cause a redirection loop because /home/example/public_html/sub is at the same place as /home/example/public_html/sub.
So, it seems sub-domains urls will always be accessible at both http://sub.example.com and http://www.example.com/sub

Again this can be done using redirects.
Thankfully, cPanel allows the sub-domain created for an add-on domain (http://example2.example.com) to be easily redirected to http://example2.com