prevent directory listing being shown on a web browser

by kalai 2008-04-30 20:34:23

How to prevent directory listing being shown on a web browser.
The simplest way is to put a dummy index.html file on that directory. This will work because the browser always searches for default files (such as index.html, index.htm, or default.html); if it cannot find any of them, then it might display the directory listing (if directory listing feature is enabled).

Another way is to set the directory permission so it's not world-readable, but make it world-executable (e.q.: chmod o+x o-r dirName). (Note: this may not work depending on your server.)

Another way is to disable directory listing through the server. You need to have access to the server to do this, and I don't think all servers support this feature.

None of these will prevent user from reading that file from the directory (if the file is already accessible from the web browser). If user know the filename on the particular directory, he/she can still access that file by typing the fill name on the browsers URL prompt.

Tagged in:

1853
like
0
dislike
0
mail
flag

You must LOGIN to add comments