How to disable directory browsing using .htaccess - Apache Web Server

apache web server, apache logo, web server, apache foundationApache web server allow directory browsing by default. It’s always good to disable directory browsing in security aspect. To disable directory browsing in apache web server you need to edit the httpd.conf or .htaccess

Disable directory browsing using .htaccess:-

  • Open your .htacces file
  • Look for Options Indexes
  • If Options Indexes exists modify it to Option -Indexes or else add Options -Indexes as a new line
  • The directory browsing feature should be disable by now

Disable directory browsing using httpd.conf:-

  • Open your httpd.conf, normally it’s located at /usr/local/apache/conf or /etc/httpd.conf
  • Go to your own Virtual Host settings and look for “Options Indexes
  • Change the Indexes to -Indexes if Option Indexes exists or else add the Options -Indexes line
  • Restart your apache web server.
  • The directory browsing feature should be disable by now

Disable directory browsing in CPanel Share Hosting enviroment:-

  • Login to your CPanel
  • Click on Index Manager
  • Directory will be list down. Click on the directory name which you want to disable the directory browsing
  • Select No Index and click Save
  • The directory browsing feature should be disable by now

Once you disable directory browsing, visitor will not able to browse your directory by accessing the directory directly (if there is no index.html file). This will protect your files from exposing to the public.

Technorati Tags: , , , , , ,

Share and Enjoy:
  • Reddit
  • BlinkList
  • del.icio.us
  • Digg
  • Fark
  • IndianPad
  • StumbleUpon
  • YahooMyWeb
Posted at March 13th, 2007 by chua

If you think this article helps you to solve your problem and clear your headache, feel free to buy me a drink :)

Related Post

7 Responses to “How to disable directory browsing using .htaccess - Apache Web Server”

  1. Shaun Says:

    Hi,

    It’s
    Options Indexes
    to turn on dir browsing
    or
    Options -Indexes
    to turn off dir browsing
    The singular version, with just the word Option, just gave me Invalid command on Apache server restart…

    cya,
    Shaun

  2. SoGua Says:

    thanks Shaun for pointing out my type error.
    I’ve corrected it.
    Hope others able to get the solution.

  3. Alejandro Says:

    And how do I do if I want to share a particular directory? Say I want my family abroad to be able to browse my pics folder, how do I set up that? I have the webserver already working with a very simple page, and I doubt the target audience will be successful using FTP, so web browsing comes to mind.

    Thanks,
    Alejandro

  4. Alejandro Says:

    nobody knows?

  5. SoGua Says:

    hi Alejandro, if u already have webserver then u can just move all your picture to the http accessible directory. If you do not wan to move then u have to configure the document root for the webserver.

  6. Nitin Malla Says:

    thank you
    its works

  7. 禁止apache目录下的文件列表 - Yingbo Miao Says:

    [...] apache中,如果一个目录没有index.html,默认会帮你生成一个, 列出目录下所有的文件。如果你不想要这个功能,可以参考这篇文章: How to disable directory browsing using .htaccess - Apache Web Server。 [...]

Leave a Reply