gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 05:29:06 26 4
gpt4 key购买 nike

我想限制对本地服务器上特定目录(以及其中所有文件)的直接访问。目录为: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 Internal Server Error,我不明白为什么。


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

最佳答案

检查 Apache 错误日志以获得准确的错误描述。

无论如何——这个错误的原因很简单: <Directory>指令不能放在 .htaccess 文件中——只能放在服务器配置或虚拟主机中。

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

关于.htaccess - htaccess 拒绝所有和 500 内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6956822/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com