1 min read
Deny directory listing with .htaccess
If you make a new directory on your website, and do not want put an “index.html” file into it, you may be surprised to find that your visitors can get a directory listing of all the files in that folder.
For Example:
For Example:
I have a directory /public_html/ABCD/
And too many sub directories into it, like
/public_html/ABCD/Test1/
/public_html/ABCD/Test1/Test/,
/public_html/ABCD/Test2/
You can see everything in that directory simply by typing “http://www.example.com/Directory_name/”
This article show you how you can configure your web server so that it does not show a directory listing by default.
Add the following line to your .htaccess file.
Options -Indexes
If you want to enable it,
Options +Indexes
If we want that some particular extension will not show than.
IndexIgnore *.zip *.css *.json *.pdf
If we want to index our files and showing it with some information than use.
IndexOptions -FancyIndexing