How to change document root using .htaccess

If you have cPanel control panel or other control panel, your website’s document root is fixed by default.

WHMCS Complete Billing and Support

However there may be a case where you need to change the defualt document for your website. This is possible via .htaccess. You will need to add the following code in your .htaccess file:

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

Replace with your actual web site name and new-folder with your new destination folder.


Posted in Apache.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.