How to change my document root folder using an .htaccess file?

By default your website is loaded from the public_html folder of your account. The public_html directory is also called web root folder or document root folder. If you've created a test website under a sub-folder and you want it to be displayed when you type your domain name, add the following lines to the .htaccess file in the public_htmlfolder:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain-name.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain-name.com$
RewriteCond %{REQUEST_URI} !folder/
RewriteRule (.*) /folder/$1 [L]

In the above lines you should replace the following 2 strings:

domain-name.com - Type your own domain name
folder - Type the name of the sub-folder which has the test/development website

If there is no .htaccess file in the public_html folder you can easily create one using cPanel->File Manager. Then, type your domain name in a browser and you should see the website which is in your test folder.

Was this answer helpful?

 Print this Article

Also Read

Can I have custom error pages?

Yes, you can set up your own custom error pages by using the .htaccess file (it is located in...

I did not receive my welcome email, but my service is listed as active

Sometimes, due to the high volume of mail we will send you in a short period of time some spam...

What are the CloudLinux (LVE) Limits?

For shared and reseller hosting the following CloudLinux (LVE) limits are in place. Please note...

How can I check how much bandwidth or disk space I am using?

If you need to check your disk space / bandwidth consumption, you can do it by checking the left...

How do I enable CloudFlare?

Enabling CloudFlare for your domain is simple and easy, and can be done in just a few short...

Powered by WHMCompleteSolution