Skip to main content

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

Comments

8 comments

  • cPRex Jurassic Moderator
    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
    0
  • markus909
    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
    0
  • cPRex Jurassic Moderator
    Are thousand over thousands of people just accepting it and dealing with it, I wonder.

    Yes, this has been how cPanel has configured sites for 23 years. I doubt we're going to make any major changes to the structure at this point.
    0
  • markus909
    Yes, this has been how cPanel has configured sites for 23 years. I doubt we're going to make any major changes to the structure at this point.

    Wow :(
    0
  • sparek-3
    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: [font="courier new">/home/user/domains/maindomain.tld [font="courier new">/home/user/domains/addondomain.tld With a symlink from [font="courier new">/home/user/domains/maindomain.tld to [font="courier new">/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 [font="courier new">/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.
    0
  • markus909
    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
    0
  • sparek-3
    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.
    0
  • markus909
    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.
    0

Please sign in to leave a comment.