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

By default your main 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 your would like to keep your site's files in a sub folder of the public_html, and do not want the sub folder to appear as a part of the URL to your website, you can mask the sub folder from the URL by placing the following directives in the .htaccess file inside the public_html folder:

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:

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 sub folder.
  • 0 Kunder som kunne bruge dette svar
Hjalp dette svar dig?

Relaterede artikler

Professional Webmaster Help

The Professional Webmaster Help service is available to all of our customers at a rate of...

[Advanced] How to Change the register_globals

ARTICLE FOR ADVANCED USERS register_globals is a setting of the PHP programming language that...

How Can I Transfer my Domain Name and Website to Solutionz-eWeb?

By transferring your domain name (or website) to Solutionz-eWeb you'll be benefiting from one of...

How to Create a favicon (website address bar icon)

What is a favicon?A favicon is a small image that is displayed in your browser next to the...

How to redirect all website visitors to a subfolder of your domain

To redirect all your visitors to a subfolder on your domain, for example www.domain.com to...