How do I change document root folder to some sub-folder using an .htaccess file?

By default the web-contents of your website will be loaded from public_html directory. If you want to load web contents from sub-folder, you can implement this by adding the following lines to the .htaccess file in the public_html folder. Note that following tutorial is only applicable to Apache web server.

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


Make sure you replace following 2 parameters in above code block.

  1. Replace domain-name.com with your actual main domain name.
  2. Replace folder-name with your sub-folder name.
  • 2 Users Found This Useful

Was this answer helpful?

Related Articles

Fix - Error 330 ( ERR_CONTENT_DECODING_FAILED)

Sometimes, you open page of your website in Firefox browser and you get following error....

Can I upgrade my shared hosting plan to VPS hosting?

Shared hosting plan cannot be upgraded to VPS hosting directly. You can purchase a separate VPS...

How to Add Domain Alias in WebsitePanel, cPanel and Plesk Panel?

This article describes how to add domain alias in WebsitePanel, cPanel and Plesk panel. Add...

Default Files and Folders in cPanel Account

While we create new account in cPanel, you may find following default files and folders:...

Fix :: Images Do Not Show up On Some WebPages in cPanel Hosting

Problem Statement One of our customer faced the problem wherein images do not show up on some of...