How To Change Document Root Folder to Some Other Directory Using .htaccess File?

 

In this Web Hosting Knowledge base article WebSouls technical team is assisting you on how to change your default document root directory;

Before knowing this let’s have brief look on .htaccess;

.htaccess files is configuration files used to manage the configuration of the Apache Web Server. By default document root directory is set to Public_html from where content your website is uploaded.

If you want to load the contact of your site from different directory kindly follow the steps given in the article below with the help of screenshots:

  

Step-1:

 

Login to your C-panel with your credentials.

 

Step-2:

 

Go to the File manager section.


 

  

Step-3:

 

Go to setting section at the top right corner in order to show dot (.) files or hidden files.

 

 

 

Step-4:

 

Select the "Document Root” for your domain and check "Show Hidden Files" (dotfiles). And click on save button.

 

 

 

Step-5:

 

Now find the .htaccess file, right click on .htaccess file and click edit from options.



 

 

Step-6:

 

You are in .htaccess file, paste the following code into the .htaccess file to change your document root folder.



RewriteEngine on

RewriteCond %{HTTP_HOST} ^domain-name.com$ [NC,OR]

RewriteCond %{HTTP_HOST} ^www.domain-name.com$

RewriteCond %{REQUEST_URI} !folder-name/

RewriteRule (.*) /folder-name/$1 [L]

 

Make sure to replace following code blocks:
Replace domain-name.com with your main domain name.

Replace folder-name with your directory path from where you want to load your site.

 

 Step-7:


Now click on save changes button in the top right corner to save your .htaccess file.

 

 

All Fine. Here are the few simple steps to change your default document root directory. If this article helps enough don’t forget to hit the thumbs up button. WebSouls is always tried to make an ease for its customer and provides the best web hosting along with domain registration in Pakistan. If you are looking to buy an affordable web hosting in Pakistan than WebSouls is undoubtedly the right choice for you.  

Team Technical Support

WebSouls

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

..htaccess guidance

  .htaccess guidance .htaccess is a special Apache file that tells your website how to...

Linux Sites preview Offline

Linux Site's Preview Offline   http://IP_address/~UserName OR http://ServerName/~userName...

How to scan your website's data from CPanel?

Welcome the comprehensive step-by-step guide by our web hosting company on how to scan your...

How Can I Download a Backup of Full cPanel Account Using FTP?

If you want to download a backup of your website using FTP, please follow these easy steps below:...

How to create an addon domain?

An add-on domain is a fully functional domain and it can be created by using your Cpanel. Add-on...