Menu Close

How to Change Your Website Root Directory with .htaccess file

IF your website is using cpanel system, your website root directory should be /home/yourusername/public-html directory. When anyone want to visit your website, the apache server will direct it to the index file in your /home/yourusername/public_html folder.

But you can change it to  different directory by .htaccess file. Just place following codes into your .htaccess file:

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

In the above lines you should replace the following 2 strings: – Type your own domain name
folder – custome the folder which hold your website