由于FollowSymLinks存在安全隐患,目前apache已经推荐所有网站使用SymLinksIfOwnerMatch。如果您碰到500 internal server error 错误,请把您网站的 .htaccess 中间的 FollowSymLinks都替换成 SymLinksIfOwnerMatch,例如
Options +SymLinksIfOwnerMatch
如果有必要也请注释掉以下代码:
Options +FollowSymLinks
htaccess配置文件,却得到了一个500内部服务器出错。
我打开我的.htaccess配置文件,发现文件头有 Options +FollowSymlinks
上网查了一下"在 某些服务器配置中,mod_rewrite要求有followsymlinks,否则会显示500内部服务器错误。
[In some (or all?) server configurations, mod_rewrite requires followsymlinks to be enabled, or it will crater with a 500-Server Error.]
在任何情况下,只要您没有指定FollowSymLinks的选项(即Options FollowSymLinks),或者指定了SymLinksIfOwnerMatch选项,Apache将不得不调用额外的系统函数来检查符号链接。每次针对文件名的请求都将触发一次检查。
如果你没有使用followsymlinks规则而网站访问正常,说明你的服务器配置已经默认调用followsymlinks的重写规则,你无需再为你的htaccess文件定义了。
止显示Apache目录列表-Indexes FollowSymLinks
如何修改目录的配置以禁止显示 Apache 目录列表。
缺省情况下如果你在浏览器输入地址:
http://localhost:8080/
如果你的文件根目录里有 index.html,浏览器就会显示 index.html的内容,如果没有 index.html,浏览器就会显示文件根目录的目录列表,目录列表包括文件根目录下的文件和子目录。
同样你输入一个虚拟目录的地址:
http://localhost:8080/b/
如果该虚拟目录下没有 index.html,浏览器也会显示该虚拟目录的目录结构,列出该虚拟目录下的文件和子目录。
如何禁止 Apache 显示目录列表呢?
要禁止 Apache 显示目录结构列表,只需将 Option 中的 Indexes 去掉即可。
比如我们看看一个目录的目录配置:
<Directory "D:/Apa/blabla">
</Directory>
你只需要将上面红色代码中的 Indexes 去掉,就可以禁止 Apache 显示该目录结构。用户就不会看到该目录下的文件和子目录列表了。
Indexes 的作用就是当该目录下没有 index.html 文件时,就显示目录结构,去掉 Indexes,Apache 就不会显示该目录的列表了。
第二种方法
解决办法:
备注: 切记莫把“Allow from all”改成 “Deny from all”,否则,整个网站都不能被打开。
可以在根目录的 .htaccess 文件中输入
<Files *>
Options -Indexes
</Files>
就可以阻止Apache 将目录结构列表出来。