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

How Do I send .eml File in Emails?

If you are facing an error like "not allowed extension file" while you send .eml file in emails,...

How to run ClamAV virus scan from cPanel?

We have installed ClamAV anti-virus plugin in our Linux Shared Server. Each cPanel user is...

What is Entry Process Limit in Linux Shared Hosting?

An Entry Process is the number of PHP scripts you can run at a time. Our Shared Hosting and...

Cpanel Email Account create Error: No specific error was returned with the failed API Call

Email account creation from Cpanel results in this error. Generally, this error is encountered...

Do you support PHP on your Servers? If yes, is it automatically available OR do I have to request for it?

PHP is available on all our Windows shared hosting and Linux shared hosting. You just need to...