Deprecated: Function create_function() is deprecated in /home2/blogwebhostingbu/public_html/wp-content/plugins/facebook-like-box-responsive/facebook-like-box.php on line 29
How to prevent directory indexing - WebHostingBuzz US Blog
Notice: Undefined variable: defaults in /home2/blogwebhostingbu/public_html/wp-content/plugins/fatpanda-facebook-comments/plugin.php on line 366
 

How to prevent directory indexing

Posted on 04 Feb 2011 by Alan Burns

When accessing a directory (rather than a page) on your site, a visitor will by default see the index page for that directory. If the directory does not contain an index file, the browser will display a list (or index) of the files in that directory.

For example, browsing to yourdomain.com/images/ would, if there were no index file (such as index.html) display a list of the contents, such as shown in this screenshot:

To prevent this directory listing, you can use an .htaccess file (a topic I’ll cover in a future article). If you’re not yet familiar or comfortable working with htaccess, there is a function in cPanel that will take care of it for you.

In cPanel under the Advanced section, click “Index Manager”. Choose public_html or whatever directory you want to change.

Index Manager allows you to customize the way a directory will be viewed on the web. You can select between a default style, no indexes, or two types of indexing. If you do not wish for people to be able to see the files in your directory, choose “no indexing”.

  1. Select the directory in which you wish to begin navigating your website’s contents using the pop-up window.
  2. To navigate Index Manager, click the folder icon next to the directory name.
  3. Click the name of the directory for which you want to change the indexing style.
  4. cPanel offers 4 options; select 1 of the following:
    • Standard Indexing: Contents appear only as filenames.
    • Fancy Indexing: Information about the files, such as the size and time last modified, appear.
    • Default System Setting: The default defined by your web host will be used.
    • No Indexing: The contents of the directory are not listed; visitors will see a message stating that the contents are “forbidden.”
  5. Click Save.

With directory listing/indexing disabled, someone visiting a directory without an index file will now see this:

cPanel creates the required .htaccess file and entries for you. Because of the way .htaccess works, your new setting applies to the current directory and all sub-directories. If you want a different setting for a particular sub-directory, just use Index Manager again for that directory and select your desired setting.

WebHostingBuzz Logo

© WebHostingBuzz USA LLC 2002 - 2024
WebHostingBuzz is a Registered Trademark.
All Rights Reserved.
WebHostingBuzz USA LLC, 850 Southbridge Street, Auburn, MA 01501, USA

1 (800) 252-1887

Payment Logos
  • Webmoney Verified
  • Webmoney Accepted

Sign up for our Newsletter

Scroll to Top