How to change the document root directory

This article describes how to change the document root directory on your cloud hosting server. This applies to all cloud hosting packages but not shared hosting packages based on cPanel.

  1. Login to the cloud panel.
  2. Navigate to Applications in the main menu and click the desired domain name.
  3. Click Site Settings in the application menu and scroll to the bottom of the page.
  4. Click the tab Custom Server Directives.

Now enter the following code into the text area. If it already holds some code, simply put it above or below the existing text.

##subroot public##

This changes the root directory to /var/www/domain.com/web/public.

Any folder can of course be used instead of public. Subfolders are also possible (e.g. ## subroot v2/root## … results in /var/www/domain.com/web/v2/root).

Click Save Changes and the document root directory should be changed within one minute.

To revert the document root directory to the default one, simply remove the above mentioned code.

Leave a Comment

Your email address will not be published. Required fields are marked *