Friday 29 April 2011

Apache: enable/disable directory browsing (file listing)


disable file listing
assume we want to disable file listing in /var/www (i.e. all directories)
$ sudo cat /var/www/.htaccess
# disable directory listing
Options -Indexes





visit page http://localhost/

Forbidden

You don't have permission to access / on this server.


Apache/2.2.17 (Ubuntu) Server at localhost Port 80
 

enable directory listing
enable directory listing in /var/www
$ sudo cat /var/www/.htaccess
Options +Indexes

specify which files to hide from listing
disable specifix file extensions from listing in /var/www
$ sudo cat /var/www/.htaccess 
IndexIgnore *~ foo1.txt

specify which files to show on listing
DirectoryIndex default.html

No comments:

Post a Comment