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

By default the web-contents will be loaded from public_html directory of your domain. If you want to load web contents from any specific sub-folder you can implement this by adding the following lines to the .htaccess file in the public_html folder:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^$ [NC,OR]
RewriteCond %{HTTP_HOST} ^$
RewriteCond %{REQUEST_URI} !folder-name/
RewriteRule (.*) /folder-name/$1 [L]
You need to replace the following 2 parameters in above code:
Write your main domain name instead of parameter.
Write sub-folder name instead of folder-name parameter.

Note: This will work for Apache web server.

Was this answer helpful?

 Print this Article

Also Read

How to install MediaWiki in Linux hosting?

For example, you wish to install Media Wiki in "wiki" folder then you should extract the...

What is Parked domain?

Pointing one domain to another domain is called Domain Parking. For e.g. ->...

Do you provide SFTP in Linux shared hosting plans?

No, we do not provide SFTP (Secure FTP over SSH). However, we support, FTPS (FTP over explicit...

How to display Awstats publicly in Linux shared hosting?

Though, there is no direct way of displaying statistics of your domain on your website, you can...

I am having an upload error. What is maximum upload limit in Linux Shared Hosting?

In Linux Shared Hosting, we have restricted the upload size limit to 2 MB but we can raise it to...