htaccess拒绝所有和500内部服务器错误

err*_*msg 2 .htaccess

我想限制直接访问本地服务器上的特定目录(以及其中的所有文件).目录是:C:/Server/www/project/html/

我尝试了下面的代码(.htaccess放在www目录 - /project/html /也不行):

<Directory "C:/Server/www/project/html/">
    AllowOverride all
        Order Deny,Allow
    Deny from all
</Directory>
Run Code Online (Sandbox Code Playgroud)

但是,它会导致500内部服务器错误,我无法理解为什么.


Apache错误日志:

[Fri Aug 05 16:06:01 2011] [alert] [client 127.0.0.1] C:/Server/www/.htaccess: <Directory not allowed here, referer: http://localhost/project/index.php?id=8
[Fri Aug 05 16:06:01 2011] [alert] [client 127.0.0.1] C:/Server/www/.htaccess: <Directory not allowed here, referer: http://localhost/project/index.php?id=8
[Fri Aug 05 16:06:01 2011] [alert] [client 127.0.0.1] C:/Server/www/.htaccess: <Directory not allowed here, referer: http://localhost/project/index.php?id=8
[Fri Aug 05 16:06:01 2011] [alert] [client 127.0.0.1] C:/Server/www/.htaccess: <Directory not allowed here, referer: http://localhost/project/index.php?id=8
[Fri Aug 05 16:06:01 2011] [alert] [client 127.0.0.1] C:/Server/www/.htaccess: <Directory not allowed here, referer: http://localhost/project/index.php?id=8
[Fri Aug 05 16:06:02 2011] [alert] [client 127.0.0.1] C:/Server/www/.htaccess: <Directory not allowed here, referer: http://localhost/project/index.php?id=8
[Fri Aug 05 16:54:12 2011] [alert] [client 127.0.0.1] C:/Server/www/.htaccess: <Directory not allowed here, referer: http://localhost/project/index.php?id=8
[Fri Aug 05 16:54:12 2011] [alert] [client 127.0.0.1] C:/Server/www/.htaccess: <Directory not allowed here
[Fri Aug 05 17:05:06 2011] [alert] [client 127.0.0.1] C:/Server/www/.htaccess: <Directory not allowed here, referer: http://localhost/project/index.php?id=8
Run Code Online (Sandbox Code Playgroud)

Laz*_*One 10

检查Apache错误日志以获取准确的错误说明

在任何情况下 - 出现此错误的原因很简单:<Directory>指令不能放在.htaccess文件中 - 仅限服务器配置或虚拟主机.

http://httpd.apache.org/docs/current/mod/core.html#directory