Knowledgebase: cPanel
HOW TO: Change the root directory of Primary domain with .htaccess
Posted by on 24 January 2019 01:10 PM


If you have a website installed for the primary domain of your hosting account, by default your website is loaded from the public_html folder. Public_html is the root folder for the primary domain and is also called web root folder or document root directory. 

If your website is located in a sub-folder of the document root and you want it to be displayed when you type your domain name, you need to edit the .htaccess file in your public_html folder. If you cannot find the .htaccess, it is possible that the file is hidden. To display hidden files on your account, follow the steps here. Or you can create one.


In the .htaccess file, you need to add the following rules to redirect the root folder:

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

You should replace the following 2 strings in the lines above: – Type the domain name in question
folder – Type the name of the sub-folder which the website is located in

After you have added the code and saved the .htaccess file, open your domain name in a browser and you should see the website which is in the sub-folder.

(1 vote(s))
Not helpful

Comments (0)
Copyright © 1998 - 2021 Shinjiru International Inc. All Rights Reserved.