The DocumentRoot is the folder of a webserver that is accessed when navigating to your website's domain name. When using a web hosting package, the /www/ folder will be set as the default DocumentRoot of your website. This means that, when you visit your domain name, the contents of the /www/ folder (your website) is served.
The folders and files inside the DocumentRoot are publically accessible. Folders and files outside of the DocumentRoot are not.
Suppose you've set the folder /public/ inside your /www/ folder as the DocumentRoot. As a result, the contents of the /public/ folder will be displayed when visiting your domain name. The other files and folders located in the /www/ folder cannot be accessed publicly and are only used for the configuration of your website. To a degree, these files and folders will be protected from the outside.
Changing the DocumentRoot
Take note: The option to change the DocumentRoot was added for our more advanced users. For this reason we recommend only changing the DocumentRoot if you're familiar with it.
In order to change the DocumentRoot of the website on your web hosting package, log in to the control panel and click 'Shared Hosting' in the menu. Next, select your domain below 'Products'.
At the top, click on 'Site' followed by 'Domains & SSL'.
On the next page you can see that the default value is being used as the 'Site path', which means the /www/ folder is used as the DocumentRoot. To configure a different DocumentRoot, click the three dots next to the domain or subdomain and select 'Edit website path'.
Now you can enter the name of the folder you want to set as the DocumentRoot and click 'Save' to save your changes.
To configure a folder within a folder as the DocumentRoot, add a ' / ' between the folders. In the example above our DocumentRoot will become the /www/public/ folder.
Applications for the DocumentRoot
Configuring a different DocumentRoot than the /www/ folder is recommended if you want to host a Laravel or Magento2 website on your web hosting package. As a rule, you will want to keep files for these types of website outside of the DocumentRoot.
Because you will want to keep certain files for Laravel and Magento2 websites hidden, it's important to set a folder inside /www/ as the DocumentRoot. That way the files and folders present in that specific folder will be accessed when visiting the website's domain name. All the other files and folders inside /www/ will not be publicly accessible; they are solely used for the configuration of your website.
Take a look at the article 'Using SFTP filemanagement in your control panel' for more information on managing the files and folders of your website via the control panel.
In order to manage your files and folders with SFTP software, you can either use Filezilla or Cyberduck. Take note that you can only change the DocumentRoot via your control panel.
In this article we discussed using and configuring the DocumentRoot for websites hosted on a web hosting package.
If you have any questions regarding this article, please contact our support team. You can reach them using the 'Contact us' button below or via the 'Contact' button inside your control panel.