Contact: Web / Voice / Email / Tips
Simple Thoughts Blog - Java and Web Technologies

Simple solutions for complex problems.

 

How To Use .htaccess to Prevent Apache HTTPD Directory Listing

March 16th, 2008 by Angsuman Chakraborty

Apache HTTPD servers are configured by default to display directory listing, when index files like index.htm or index.html of index.php etc. are not present in the directory. This can expose sensitive information to prying eyes and are often indexed by search engines. This can compromise your data by making it visible to unintended audience. The solution is simple. You can add a line to your .htaccess file (create the file if not present) to prevent directory listing for that directory and its sub-directories:
IndexIgnore *

The * matches all files in the directory. You can also restrict only a subset of file from being displayed. For example if you would want the directory content to be listed but not include the images in the listings then you should use this command:
IndexIgnore *.png *.gif *.jpg

This would return a list of all files not ending in .png, .jpg or .gif, but would still list .txt, .html, etc.

On the other hand if your server is setup to prevent directory listing, but you want to list the directories by default, then add the following in your .htaccess file:
Options +Indexes


Tags: Apache HTTPD, Headline News, How To, Open Source Software, Web | | RSS 2.0 | Trackback this Article | Email this Article

You may also like to read

»Apache HTTPD: How To Turn Off Index Listing in Directory & Sub-Directories; Protect WordPress wp-content
»How To Run PHP in HTML Pages
»How To Enable / Use .htaccess / Nice permalinks in Apache Web Server on Windows
»mod_rewrite Not Working in .htaccess - Solution
»Cool SEO Redirection Feature in WordPress 2.3.x
»Tomcat 5.5 with Apache 2.0 Integration in 5 Simple Steps
»How To Migrate Mantis Defect Tracking System From Windows To Linux / Fedora Core 6
»How To Configure PHP 5 With Apache 2 On Windows in 2 Minutes
»Compressing php output with wp-cache2 WordPress Plugin
»3 Ways To Selectively Execute HTML Files Using Apache HTTP Server
»How To Use Apache HTTP WebDav Server With Windows XP Explorer
»Simple .htaccess Rules To Block Spammers
»How To Enable Nice Friendly URL in Vanilla Forum
»How to Determine if your Sensitive Data is Safe in Shared Hosting
»How To Run Ant FTP / Telnet / Rexec Task

Looking forward to hear your thoughts.



Please enter the code shown below ( to verify that you are human ) before you click Submit Comment.

No. 1 method to ethically increase your blog traffic and reach.

Translate

Translate to EnglishÜbersetzen Sie zum Deutsch/GermanPřeložit do Čech/CzechOversætte hen til Dansk/DanishKääntää jotta Finnish/FinnishLefordít -hoz Magyar/HungarianÞýða til Íslenska/IcelandicTraducir a Latinoamericano Español/Latin American Spanishtagapagsalin sa Filipino/FilipinoTłumaczyć wobec Polski/PolishA traduce la spre Român/RomanianPrevesti za Srpski/Serbiantolmačiti v slovenski/SlovenianÖversätta till Svensk/SwedishChyfieitha at Cymraeg/Welshtercüme etmek -e doğru Türk/TurkishPrevesti to Hrvatski/CroatianПревеждам към Българин/BulgarianTraduzca al Español/SpanishTraduisez au Français/FrenchTraduca ad Italiano/ItalianTraduza ao Português/Portuguese日本語に翻訳しなさい /Japanese한국어에게 번역하십시오/Korean中文翻译/Chinese Simplifiedترجمة الى العربية/ArabicVertaal aan het Nederlands/DutchΜεταφράστε στα ελληνικά/GreekПереведите к русскому/RussianOversetter til Norsk/Norwegian中文翻译/Chinese TraditionalTraduzir a Língua portuguesa brasileira/Brazilian PortugueseReddo ut Latin/Latin

Taragana Network

»Ctrl-S
»Enterprise Blog
»Free Book on Eye Care by Natural Therapy
»Health Care Blog
»Hot Computer Jobs Blog
»Pet Care & Grooming News and Tips
»Phil Law Blog
»Taragana - Software Outsourcing
»The Angsuman Chakraborty Blog
»The Diabetes Cure Blog
»The Eye Treatment Blog
»The Stem Cell Blog
»Weblog Hosting Blog
"A man's ethical behavior should be based effectually on sympathy, education, and social ties; no religious basis is necessary. Man would indeeded be in a poor way if he had to be restrained by fear of punishment and hope of reward after death." - Albert Einstein