How do I disable directory browsing?

后端 未结 12 802
灰色年华
灰色年华 2020-11-22 08:35

I want to disable directory browsing of /galerias folder and all subdirectories

Index of /galerias/409

* Parent Directory
* i126937298         


        
12条回答
  •  甜味超标
    2020-11-22 09:03

    You can place an empty file called index.html into each directory that you don't want listed. This has several advantages:

    • It (usually) requires zero configuration on the server.
    • It will keep working, even if the server administrator decides to use "AllowOverride None" in the the server configuration. (If you use .htaccess files, this can lead to lots of "Error 500 - internal server error" messages for your users!).
    • It also allows you to move your files from one server to the next, again without having to mess with the apache configuration.

    Theoretically, the autoindexing might be triggered by a different file (this is controlled by the DirectoryIndex option), but I have yet to encounter this in the real world.

提交回复
热议问题