How do I disable directory browsing?

后端 未结 12 592
灰色年华
灰色年华 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 08:57

    Edit/Create an .htaccess file inside /galerias with this:

    Options -Indexes
    

    Directory browsing is provided by the mod_autoindex module.

    0 讨论(0)
  • 2020-11-22 08:58

    If you choose to modify your httpd.conf file to solve this and you have multiple Options directives, then you must add a - or a + before each directive. Example:

    Options -Indexes +FollowSymLinks

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-11-22 09:08

    Create an .htaccess file containing the following line:

    Options -Indexes
    

    That is one option. Another option is editing your apache configuration file.

    In order to do so, you first need to open it with the command:

    vim /etc/httpd/conf/httpd.conf
    

    Then find the line: Options Indexes FollowSymLinks

    Change that line to: Options FollowSymLinks

    Lastly save and exit the file, and restart apache server with this command:

    sudo service httpd restart
    

    (You have a guide with screenshots here.)

    0 讨论(0)
  • 2020-11-22 09:10

    Open Your .htaccess file and enter the following code in

    Options -Indexes
    

    Make sure you hit the ENTER key (or RETURN key if you use a Mac) after entering the "Options -Indexes" words so that the file ends with a blank line.

    0 讨论(0)
  • 2020-11-22 09:12

    Try this in .htaccess:

    IndexIgnore *.jpg
    
    0 讨论(0)
提交回复
热议问题