Subdirectories – 3 Ways To Hide Them Through CPanel

When creating a website, by default, all of the subdirectories within the “public_html” directory can be easily viewed by the public, hence the “public” part of the title. Basically, anyone can look up the contents of that directory and subdirectories, such as any files, photos, documents, etc. that you may not necessarily want anyone to see. However, here are 3 ways that you can hide or make these subdirectories invisible to the public:

5 Stars Hosting cPanel

I. Create An Index.html File Through cPanel

    1. Log into your cPanel account

     

    2. Under the “Files” section, click “File Manager”

    3. With the “Home Directory” radio button selected, click “Go”

    4. Under the “public_html” directory on the left side menu, click on a subdirectory that you would like to hide. (If the subdirectories are not visible, click on the “+” sign to the left of “public_html” to collapse and show all of the subdirectories)

    5. Click on “New Folder” on the top menu

    6. Type in “index.html”as the “New Folder Name:”

    7. Click “Create New Folder”

Note:
In order to hide all subdirectories, you will have to create an index.html file for each.


II. Use Index Manager In CPanel

    1. Log into your cPanel account

     

    2. Under the “Advanced” section, click “Index Manager”

    3. With the “Web Root (public_html/www)” radio button selected, click “Go”

    4. Click on “/ public_html /”

    5. Click on the “No Indexing” radio button

    6. Click “Save”

Note:
This will hide all of your public_html subdirectories and will show a “Forbidden” and 404 Not Found error message.


III. Use Redirects Tool In CPanel

    1. Log into your cPanel account

     

    2. Under the “Domains” section, click “Redirects”

    3. Select the domain name in the drop down menu next to “http://(www.)?”

    4. In the text box to the right, type in the name of the subdirectory that you want to redirect

    5. Next to “redirects to?” enter the location/domain name that you want the subdirectory to go to

    6. Click “Add”

Note:
In order to hide all subdirectories, you will have to redirect each one.

If you have experience with .htaccess, here’s how to do redirects manually:

    1. Download the .htaccess file

     

    2. Open the file in a text editor (e.g. Notepad)

    3. Use the following code below to redirect (replacing “domain.com” & “subdirectory” with your names)

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} ^www.domain.com$
RewriteRule ^subdirectory\/?$ “http\:\/\/domain\.com\/” [R=301,L]

Note:
In order to hide all subdirectories, you will have to redirect each one.

  • 9 Users Found This Useful
Was this answer helpful?

Related Articles

MySQL Databases – How To Create, Import & Export Through cPanel

Creating a MySQL Database 1. Log into your cPanel account and go to the MySQL Databases...

Domain Name: How To Change The Main Domain Name On Your Account

To change your main domain name on your web hosting account, you usually have to go through your...

PhpMyAdmin & cPanel: Optimizing a Database

Keeping your database(s) optimized is always a good step to take to help keep your website or...

DNS – How To Customize Your Records

What Is DNS? DNS (Domain Name System) is a database system that the Internet uses to translate a...

cPanel: Starting Up Your Hosting Control Panel

With 5 Stars Hosting, the specific control panel for your hosting account is cPanel. It allows...

Powered by WHMCompleteSolution