When you create a sub-domain, cPanel points it to the corresponding folder under public_html by default. How to point it to a folder outside the public_html?
This cannot be done via cPanel/WHM but can be achieved if you have ‘root’ SSH access to the server.
1. Open the apache configuration file — /usr/local/apache/conf/httpd.conf
2. Search for the virtual host entry for your sub-domain.
3. Edit the document root of your sub-domain to match the desired location.
4. Save and Exit. Restart apache.
Note : cPanel rebuilds httpd.conf from userdata files and its overwritten on every cPanel update, on every account creation, subdomain addition, or any such activity related to apache and any manual changes you make will be overwritten. To make permanent changes to a subdomain’s root folder :
1. Edit the file /var/cpanel/userdata/username/subdomain.domain.com file, change the path and save it.
2. Run /scripts/rebuildhttpdconf
3. Restart apache.
To learn how you can preserve the changes in httpd.conf during EasyApache, click here.