Howto: Disable directory listing using .htaccess

prevent directory listing

If you want to preventing directory listing / prevent your server from displaying entire content of directory, here some tips :

1. Add an empty file named index.htm or index.html or index.php; this will show a blank page for the directory.
2. Add / edit your .htaccess file, and add this code

Options -Indexes

this will throw a 403 Fobidden  HTTP respose. a – (minus) sign tells Apache to do not index / listing file in the current or sub directory.
3. For a specific file do not allow to list you can modify .htaccess file with this code

IndexIgnore *.zip *.jpg *.gif

This will hide all files with .zip ,  .jpg and .gif extension.

PS: this tips works on apache http server only. :)

Related posts:

  1. Enable HTTP compression with Gzip
  2. URL Rewrite
  3. Handling file upload using PHP Script

2 Responses to “Howto: Disable directory listing using .htaccess”

  1. emang kalo ga pake dimodif gitu, seluruh directory bisa kelihatan ya?

    [Reply]

  2. @joanne : iya bisa kliatan tuh.. orang2 jadi bisa browse file2 kita di web :) thx for your visit ^_^

    [Reply]

Leave a Reply