Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  How-Tos  >  How To Change Document Root Using .htaccess File?
Top Scroll

How To Change Document Root Using .htaccess File?

 2 min

Watch this video for a step by step process on how to change document root using .htaccess file?

The time your account is created on a shared hosting/reseller hosting, by default the website loads from public_html directory. This directory is the Document Root OR the web directory. What if you want the website content to load from some other directory OR a sub directory ?

Simply, add the code below in .htaccess file under the account. You can create the .htaccess file using File Manager from cPanel. It will redirect to the sub directory when your domain is accessed.

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

Make sure you replace with your actual domain name & web with your actual sub folder.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
Claim the discount before it’s too late. Use the coupon code:
Note: Copy the coupon code and apply it on checkout.