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

The time your account is created on a shared/reseller host, 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} ^domain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) /web/$1 [L]

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

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