How do I restrict Sub/Addon domains DocumentRoot outside of public_html ?
Linux Fully Managed Dedicated Server comes with full root access and standard cPanel/ WHM where you will get a control to make any changes at anytime. You will also get a SSH access to manage via SSH.
Using cPanel’s Domain options you can easily create Addon/Sub-domains in the server. cPanel allows the users to perform various kind of operations like creating sub-domain,Addon Domain and Parked domain etc., cPanel provides user friendly access to the users, even the beginners also can easily do any kind of tasks.
When adding an Addon or Sub domain, the default DocumentRoot on cPanel servers /home/user/. If you dont want to set the DocumentRoot outside public_html when adding Addon/Sub domain, you can follow the below procedure.
Refer the below procedure to restrict sub-domain/Addon domain document root outside of mail domain “public_html”.
Via WHM :
1. Login to the WHM as a root
2. Go to “Tweak Settings” under Server Configuration
3. Choose Domains option
4. Click on “Restrict document roots to public_html” and Choose “ON”
This option mandates that document roots for all newly-created websites must reside under the document root for the account’s primary website. This option does not apply when you transfer or restore accounts.
5. Click on Save. Now you can create Addon/Sub domain DocumentRoot only inside public_html
(Ex: /home/user/public_html/addondomain.com)
When set to ON it prevent users from creating subdomains and Addon domains outside of their public_html directory.