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

Parse ASP pages as normal Text/HTML in cPanel server using MIME type

Problem statement One of our customers had some old .ASP file names on his website. The web...

A subdomain that I have created isn't working.

Please note that subdomain requires DNS propagation and it may take upto 24 hours. If DNS...

How to Change PHP Version From cPanel?

This article will assist you to change PHP version from cPanel. Please note that the option of...

How do I create SRV record for my domain?

This article will assist you to add an SRV record to your domain. Services Resource Record (SRV)...

How Do I Fix 403 Forbidden Error?

The 403 Forbidden Error indicates that your website files have incorrect permissions. Every...