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 the public_html directory. If you want to load web contents from a sub-folder, you can implement this by adding the following lines to the .htaccess file in the public_html folder. Note that the following tutorial is only applicable to Apache webserver.

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 the 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.

→ Looking to move wordpress from root directory to sub-directory? Please refer to move wordpress to the sub-directory for more details.

Related Articles

How to Manage Shared cPanel Account from Client Area?

This article will assist you to manage your Shared linux cPanel account from client area. At...

What is parked domain?

Pointing one domain to another domain is called Domain Parking. Both Parked domain and Main...

How Do I Fix 403 Forbidden Error?

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

When I connect to FTP account through filezilla it always says certificate is unknown. What am I missing here?

This error is common because FTP service of our shared server is bound with server's Self-Signed...

Password Policy For Shared Hosting Email Accounts

Linux Shared Hosting cPanel/WHM enables admins to define the minimum password strength for all...

  • 2 Users Found This Useful

Was this answer helpful?