One of the best things I love Apache web server is that it instantly enables you to share files and resources via plain web directory index listing without having to spend time making any fancy web pages to serve them.
However, there are times when you need to hide things out. To disable web directory listing, you need just a simple directive in .htaccess of that directory. Insert this line to disable apache files listing for this directory and all directories or folders underneath it:
Options -Indexes
However, you may need to specifically enable file indexing for some directory under the parent directory. Just override the above .htaccess directive by creating another .htaccess in the child directory and write:
Options +Indexes
Enable fancy indexing
Fancy indexing is a bit more sophisticated than plain indexing in that it explicitly presents file types and image icons (icons are small images that boost user experience by conveying the idea very intuitively, such as these flag icons standing for countries) for easy discrimination. You can enable fancy indexing for a directory listing by adding an additional directive:
Options +Indexes
# adding fancy directory indexing
IndexOptions +FancyIndexing
# is the comment symbol for .htaccess directives.
Exclude certain files from indexing
There might be confidential files you want to exclude from the indexing and stop them from being shown to visitors. The directive below helps you achieve this task:
IndexIgnore *.jpg *.gif readme.txt
Very straightforward and self-explaining, just modify it for your own situations.
You should also read:
- PHP: Run .CSS files as PHP
- 12 Most Used .htaccess Examples, Tips – Commands & Directives
- .htaccess: Deny From All – Prohibit, Forbid or Restrict Directory Access
- PHP: open_basedir in php.ini to Restrict and Limit PHP File Accesses to a Certain Directory
- One SSI directive to save all programming muggle’s effort and time


Facebook
Twitter
Google Plus
{ 1 comment… read it below or add one }
Thanks for the tips — just what I needed, since GoDaddy.com has fancy indexing disabled by default. This allows me to activated it on a per-directory basis.