Htaccess – Prevent Unauthorized Directory Browsing

Prevent unauthorized directory browsing by instructing the server to serve a “xxx Forbidden – Authorization Required” message for any request to view a directory.

For example, if your site is missing it’s default index page, everything within the root of your site will be accessible to all visitors. To prevent this, include the following htaccess rule:

# disable directory browsing
Options All -Indexes

Conversely, to enable directory browsing, use the following directive:
# enable directory browsing<br /> Options All +Indexes

Likewise, this rule will prevent the server from listing directory contents:
# prevent folder listing<br /> IndexIgnore *

And, finally, the IndexIgnore directive may be
used to prevent the display of select file types:

# prevent display of select file types<br /> IndexIgnore *.wmv *.mp4 *.avi *.etc

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

More in Software, Tips (69 of 193 articles)


Have you ever noticed that many blogs put up a daily post that is simply a bunch of links to ...