HostOnNet Blog

How to Change Document Root of Website Using .htaccess

By default the document root of website on a cPanel server is /home/username/public_html .

At the time anyone search a domain from there own end the site displays the index page from default location.

That means from public_html folder. Here I’m explaining the way to change this default folder. That means you can customize the Index page fetching from your own folder.

This is possible via .htaccess. You will need to add the following code in your .htaccess file

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

Replace ‘’ with your domain name and ‘folder’ with your custom folder name where you kept the index.

About Annie

I've been working in Technical Section for over 10 years in a wide range of tech jobs from Tech Support to Software Testing. I started writing blog for my future reference and useful for all.
Posted in Cpanel Server, DNS