How to disable directory indexing from apache2 when going to the server's root?

后端 未结 6 2275
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-12 12:11

I need to disable that indexing when I enter on my root directory on a apache2 server, any tips?

6条回答
  •  南旧
    南旧 (楼主)
    2021-02-12 12:44

    If you have the a2dismod utility on your distro you can remove the module entirely if you don't need directory indexes at all:

    sudo a2dismod --force autoindex
    

    Use the --force or -f flag to avoid the following warning:

    WARNING: The following essential module will be disabled.                                                                                                                   
    This might result in unexpected behavior and should NOT be done                                                                                                             
    unless you know exactly what you are doing!                                                                                                                                 
     autoindex                                                                                                                                                                  
                                                                                                                                                                                
    To continue type in the phrase 'Yes, do as I say!' or retry by passing '-f': Yes, do as I say!                                                                              
    Module autoindex disabled.                                                                                                                                                  
    To activate the new configuration, you need to run:                                                                                                                         
      systemctl restart apache2
    

    Here are the docs for mod_autoindex

提交回复
热议问题