HomeApacheChange the document root using .htaccess file

Change the document root using .htaccess file

The public_html directory is your webroot directory. By default your website is loaded from public_html folder. If you create a website under a sub-folder and you want to display it when you type the domain name, add the following lines to your .htaccess file.

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

Replace domain.com with your domain name. Replace folder with the folder having your website.

Incase there is no .htaccess file you may create a new .htaccess file using filemanager in cpanel.

Scroll to Top