Directory browsing is when you can see all files and folders in a particular directory by name when you enter the address in your web browser. You will see a complete list of files and folders. You can then click on them individually. Which means you can see files that oftentimes you would rather your visitors not see or access.

Most people won't bother, but there is always someone that is more than willing to see what you got in there.

The long and time consuming way is to just create or add a blank index.html or index.php file in each folder that doesn'talready have one.

This is kind of a pain and time consuming, and in Dolphins case difficult to find them all due to the numerous directories/folders and
sub-directories/sub-folders. You will undoubtedly miss a few of them in the process.

Many people are not aware of this but you can simply add one very small line of code to your main .htaccess file and prevent all of this
with one pop. All directories and sub-directories will be covered if you add it to the main .htaccess as they all obey the main .htaccess

If you have cpanel hosting there is even an option in cpanel to set this with a few simple clicks. Simply find "Index Manager" and turn off index directory browsing.

However, if you have any customizations to .htaccess it is sometimes better to manually do this and is actually faster.

You should download your main .htaccess file prior to editing it, just in case. One thing about .htaccess is it is a very sensitive file.
If just one little character is off or mistyped it will error your entire site out. So if this happens you can simply upload the backup
.htaccess before your changes and try again.

Once you get the hang of .htaccess it is really quite simple. It is very powerful and you can do so many things with it. It's kind of the
brains of your site. Any time a visitor comes to your site, the .htaccess file is checked before they are allowed to do anything. You can
block people, redirect pages, re-write URL's, prevent user agents and bots, and much more.

Ok back to the simple task of preventing it.

First download the main .htaccess file for your site to your local PC and keep it in a safe location you will
remember (yoursite.com/.htaccess).

Now open it/edit on your server or download another and edit it with a standard text editor and near the top simply add this code at or near the top:
Options -Indexes

So yoursite.com/.htacess file might look something like this:
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
(more .htaccess code here)

That simply tells Apache no indexes (-Indexes).

This will take care of ALL directories/folders that don't have an index.html or index.php file in them in one pop. If anyone now tries to browse to a location without an index file they will see a "403 Error" or "Forbidden Message".

This helps keep your files, pictures, and other data a little more private.

If you do not want your entire site to have no index browsing you can add Options -Indexes to any folder you want instead and it will cover all locations under it. If there is no .htaccess in the particular directory/folder you can simply create one/upload

Or if you want your entire site to have the Options -Indexes you can add Options -Indexes to your main .htaccess file. Then, in the folder that you do want to allow browsing you simply add to the .htaccess file in this one folder Options +Indexes to allow only this one. All the others will be disallowed by the main .htaccess, and this one only will be overridden.

Any problems simply restore the backup .htaccess file you downloaded, re-read these instructions and try again.


How to turn off Directory Browsing using Cpanel:

If you prefer to give cpanel's "Index Manager" a try instead, you should still download a backup of your .htaccess file as cpanel will try to automatically apply the changes for you. If you have customizations to .htaccess cpanel sometimes messes up.

Find and click on "Index Manager" in Cpanel.
Cpanel Index Manager

A box will open similar to this. Simply click on go to continue.
Select Directory or Site

If you want to turn of browsing site wide then click "public_html" as pictured:
Select Public Html

You will see a screen like this:
Default Settings

Change to "No Indexing" and save the changes:
No Indexing

If you want "No Indexing" in specific directories/folders rather than site wide, then you would need to select the particular folder instead of "public_html" in the previous step. Then select "No Indexing" and save the changes. That will only effect the particular folder and all locations under it.

Whether you use cpanel, or manually edit .htaccess just be sure you back up any .htaccess file/files in question prior to attempting.

.htaccess can be a pain, it's very particular and needs to be exact.

Written By
Tutorial by: Jeremy LeSarge (AKA Ray)

I am the owner and administrator of DialMe.com. I write Tutorials for Boonex Dolphin as well as tips and resources surrounding website programming and development. I enjoy working with WordPress, SEO, and Web Hosting / Servers. I also maintain a WordPress Blog here on this site where you will find a variety of technology and webmaster resources.

Sponsored Links