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

时间:2011-08-05 13:11:38

标签: .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>

但是,它会导致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

2 个答案:

答案 0 :(得分:10)

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

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

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

答案 1 :(得分:0)

对我而言,需要启用头模块到apache