How to change document root for a domain in cPanel using .htaccess

How to change document root for a domain in cPanel using .htaccess

Here is how to change document root for a domain in cPanel using .htaccess file:

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

*where domain.com is your domain name and folder is the new document root

For more .htaccess snippets check My .htaccess Cheatsheet

whoami
Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.