我想修改在Windows中运行的Apache的httpd.conf文件,但是我想知道为什么需要使用(或声明)两次相同的根。
DocumentRoot "C:/Apache/htdocs" <Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory> <Directory "C:/Apache/htdocs"> AllowOverride None Order allow,deny Allow from all Options None </Directory>
如果第一个 具有所有关于安全性或访问权限的文档根目录 ,为什么需要重新声明
在这种情况下是不同的,我可以通过最后的声明:<Directory“C:/ Apache / htdocs”>?
Apache可以运行省略最后一个<目录“C:/ Apache / htdocs”>?
我找不到这个意思。
谢谢。
我来自UNIX / Linux领域,但是我认为你对configuration略有误解。 让我们把你的configuration分成3部分(好吧,它已经在3部分)。
首先,DocumentRoot是完全独立的,忽略这个问题。
其次,“Directory /”被configuration为拒绝所有 。 这不是你的DocumentRoot,这是你的文件系统的根(我真的不知道Apache是如何在Windows上解释这个的,但是Linux和UNIX是这样的)。
第三,“目录”C:/ Apache / htdocs“被configuration为允许来自你的DocumentRoot的所有文件。
这是基本的Apache性能和安全性调优,可能是目前Apache HTTPD几乎所有发行版的默认configuration。
第一个目录列表中的“AllowOverride None”保持Apache不检查覆盖文件(.htaccess文件)的文档根目录下的每个目录。
从Apache文档: When this directive is set to None, then .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the filesystem. When this directive is set to None, then .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the filesystem.
所以,如果你删除了“Directory /”节:那么Apache会在到达“Directory C:/ Apache / htdocs”目录之前查找c:/。htaccess和c:/Apache/.htaccess。 因为为c:/ Apache / htdocs设置了“AllowOverride None”,所以不会再烦恼。 您的网站将会加载,但是您不必要地增加了Apache为提供服务所做的工作。
现在,如果你删除“目录”C:/ Apache / htdocs“'节:然后你坚持”目录/“的设置,其中包括”全部拒绝“。 您的网站将无法加载。
这个configuration对我来说看起来是正确的。