Main domain and add-on domains both in separate folder in public_html

markus909

Active Member
Feb 18, 2023
44
10
8
Austria
cPanel Access Level
Reseller Owner
I am new to cPanel but worked with it intensively for 1 to 2 weeks in a reseller account.

I want to setup my accounts in a way that does not look difficult at first, but well .. it seems it might be not work out of the box.

I just want to have the main domain + additional addon domains in their separate folders and have a clean structure
e.g.
I want this
website1: /public_html/mymaindomain.at
website2: /public_html/dev.mymaindomain.at

But I only get this
website1: /public_html/
website2: /public_html/dev.mymaindomain.at

Its getting more important to have a clean structure when there are more addon domain in the account.

How can I do that with cPanel on a Reseller account?
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
17,470
2,843
363
cPanel Access Level
Root Administrator
Hey there! There isn't really a way to do this in cPanel, especially with a reseller account. If you had full root access you could potentially edit come configuration files on the system to manually do this, but it's still not recommended. In general, the main domain will always be public_html and the other domains will be in the public_html/otherdomainfolder
 

markus909

Active Member
Feb 18, 2023
44
10
8
Austria
cPanel Access Level
Reseller Owner
Hey there! There isn't really a way to do this in cPanel, especially with a reseller account. If you had full root access you could potentially edit come configuration files on the system to manually do this, but it's still not recommended. In general, the main domain will always be public_html and the other domains will be in the public_html/otherdomainfolder
Thanks for letting me know .. even though that is actually a terrible implementation. It only screams for problems, e.g. backup from main domain or migration between live and staging includes the subfolders. Did you come up with a workaround or was it just too risky?

I imagine that the live site is the main domain, and the staging site is the addon domain. It could happen that you migrate the live to staging and it included itself in the subfolder.

This is juts not a clean solution at all. I read many posts from the last 10 years about this topic now during the last days. Honestly, that alone is reason to turn away from cPanel and my hosting provider and go somewhere else.

Are thousand over thousands of people just accepting it and dealing with it, I wonder.

On a test account I followed the following tutorial and managed to get it the way I want
  • website1: /public_html/mymaindomain.at
  • website2: /public_html/dev.mymaindomain.at

However...
  1. setup is more complicated
  2. I am not an expert in this, so I don't know what problems I get with that in the long run (it's a workaround and not a solution overall)

My hosting provider told me also it's not really possible, however, I am allowed to put the addon domains directly under root as another workaround. At least this would feel more structure
  • website1: /public_html/wp-content
  • website2: /public_html_myaddon/wp-content
  • website3: /public_html_myaddon2/wp-content

Anyone know if we can expect a change actually or is this more like staying forever?
 

sparek-3

Well-Known Member
Aug 10, 2002
2,183
285
388
cPanel Access Level
Root Administrator
When cPanel first came out - many, many, many moons ago - there was no such thing as addon domains. I'm not really sure if the first versions of cPanel even included subdomains. I think it may have been just one domain, period. The public_html folder made sense then.

But with the creation of addon domains on a cPanel account, I do agree that a structure change PROBABLY should have been made. Something like:

/home/user/domains/maindomain.tld
/home/user/domains/addondomain.tld

With a symlink from /home/user/domains/maindomain.tld to /home/user/public_html to keep backwards compatibility. But that didn't happen.

It would make changing an addon domain to the main domain a lot easier, since structurally all that would need to be changed would be the symlink to /home/user/public_html.

I'm not really that upset that the structure was never changed. But I do think it's an example of poor foresight and perhaps not expecting the proliferation of addon domains within a single cPanel account. Making such a change now is probably not the best idea since some users tend to put all of their addon domains DocumentRoots under the public_html folder AND reference PHP includes from within the public_html structure using relative path names. Again this is where foresight and planning can pay dividends later down the road and lacking that foresight and planning can take a lot of options off the table.
 

markus909

Active Member
Feb 18, 2023
44
10
8
Austria
cPanel Access Level
Reseller Owner
Thanks for the additional clarification and explanation. Having a website-root-folder (addon) inside another website-root-folder (main) is a no go for me, to be honest, This can and will lead to problems, I am sure.

I never thought about this before, as I just start out with those things and just know all possible shared hosting panels. But perhaps people make a decision with which hosting company they go based on the specific control panel (cPanel, Plesk, Webmin, etc.)

It makes sense, to go for another hosting provider, when some limitations come from the control panel software e.g. the example in this thread with the folder structure, but another example would be that there is only 1 cPanel user per account. I just learned that Manage Team is on the way to come (I assume this can take years though). If I need that now, I basically need to look if other control panel software supports it. Just sound all so basic to me - hence I am surprised (but also grateful to find answers in this community)

Would you think this structure as a workaround for that limitation will lead to problems?
website1: /public_html/wp-content
website2: /public_html_myaddon/wp-content
website3: /public_html_myaddon2/wp-content
 

sparek-3

Well-Known Member
Aug 10, 2002
2,183
285
388
cPanel Access Level
Root Administrator
I suppose cPanel's "fix" for this issue is allowing you specify a DocumentRoot for any addon domain within the path of the account's home directory.

I seem to recall - although I'm not 100% sure of this - when addon domains were first made available in cPanel they had to have their DocumentRoot inside the public_html directory.

With cPanel allowing you to specify the DocumentRoot of an addon domain relative to the account's home directory, then you can specify anything and structure this any way you want to.

It's just if you have a lot of addon domains, then the "main" domain tends to become the black sheep because it's DocumentRoot is going to be "public_html". What domain name is that DocumentRoot referring to?

Again I should stress, I don't really have an issue with the way cPanel is doing all of this. But I do understand where there can be some confusion with this structure and where it could be improved. But I also think the time to "fix" this structure has long since sailed away.
 

markus909

Active Member
Feb 18, 2023
44
10
8
Austria
cPanel Access Level
Reseller Owner
With cPanel allowing you to specify the DocumentRoot of an addon domain relative to the account's home directory, then you can specify anything and structure this any way you want to.
Yes, I think that's what I am going to do if I stay with cPanel. Addon domains would be either directly in /home or collected in a separate directory e.g. /home/domains

It's just if you have a lot of addon domains, then the "main" domain tends to become the black sheep because it's DocumentRoot is going to be "public_html". What domain name is that DocumentRoot referring to?
Exactly, the main domain is the black sheep then. Well said. I need to check and play around with the configuration, as I don't know yet what I can do there with DocumentRoot. I would guess DocumentRoot will always be /public_home as the main domain will always be there.

Again I should stress, I don't really have an issue with the way cPanel is doing all of this. But I do understand where there can be some confusion with this structure and where it could be improved. But I also think the time to "fix" this structure has long since sailed away.
I get it of course ... if you are long enough in it, you just know the ins and outs of it. You avoid setups and configurations that you know that could mess something up. As a new user, I see it very differently obviously. Not just because I want a clean structure (OCD calling here), but also to avoid errors.

Did it ever happen that you made a mistake when it comes to backup / restore / pushing & pulling of staging and live system when another website lives inside the main website? Did you ever needed to create a folder and you could not because the folder name is used by the addon domain? I don't know yet what all the consequences are or can be of that outdated cPanel structure. Probably there are not too many and it's really just my OCD scaring me away of it. But I better understand now what this means than later. I also have to add, that all the non cPanel hosting providers I used so far, had a what I call "normal" structure.