How to change the document root (web root) for a website

By default on a STORM server your websites document root will be set to the “public” folder. However you may want to set the document root to another folder within the site. To change the folder that your website loads from on a STORM server you will need to add some config to your sites .htaccess file.

The first thing to do is to make sure that within the “public” folder you have a .htaccess file. 

If there isn’t one you can simply create the file and add the below config to the file to this:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^nimbustest.com$ [NC,OR]

RewriteCond %{HTTP_HOST} ^www.nimbustest.com$

RewriteCond %{REQUEST_URI} !newwebroot/

RewriteRule (.*) newwebroot/$1 [L]

You will then need to tweak the config for your sites URL and folder.

In this example the domain name of the site is nimbustest.com so replace “nimbustest.com” & “www.nimbustest.com” with the domain name of your website.

And the folder we have set the site files to load from is public/newwebroot so replace “newwebroot” with the folder you would like your files to run from.

Once you have added the config correctly, there’s no need to restart any services on the server. Simply upload your web files to the folder you have created and these will now be served from this folder instead of the “public” directory.

Nimbus Hosting
1 Centrus, Mead Lane Hertford Hertfordshire SG13 7GX GB 0203 005 9181 [email protected]
×