我不想使用.htaccess。我该如何更改目录属性?
<VirtualHost *:80>
ServerName abc.com
DocumentRoot /usr/share/uploads
<Directory " /usr/share/uploads">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
答案 0 :(得分:50)
如果您使用的是Debian / Ubuntu,只需转到终端并输入
即可sudo a2dismod autoindex
sudo service apache2 restart
如果您使用的是Centos / Fedora,请执行以下操作:
mv /etc/httpd/conf.d/autoindex.conf /etc/httpd/conf.d/autoindex.bkp
/etc/init.d/httpd restart
同样在其他操作系统或发行版......
这应该禁用apache模块,使那些花哨(通常无用且安全问题)的目录列表。此外,作为奖励,您可以获得一些表现: - )
答案 1 :(得分:24)
我真的无法在互联网上找到直接答案;甚至在apache文档上。最后,可以通过几次迭代找到解决方案;我们需要使用Options,值不应包含Indexes。
<Directory "/usr/share/uploads">
Options Includes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
答案 2 :(得分:4)
@Deepak解决方案对我不起作用。这个做了:
在主要的快速配置 /etc/apache2/httpd.conf 中添加:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
它适用于所有域和子域。没有.htaccess文件。
答案 3 :(得分:1)
以上所有内容都已完成,但目录信息仍在进行中? 如果您使用index.php而不是index.html,请检查以下内容:
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
答案 4 :(得分:-1)
最简单的方法是在该目录中放置一个空的index.html(或者默认配置为apache的任何配置)。 这不是真正的解决方案,而是一个非常简单的解决方法。浏览该目录的用户只会看到一个空白页面。
此外,您可以使用一个脚本(如index.php)来模拟目录列表,只显示一些特殊文件。