【问题标题】:500 server error when denying access to subdirectory拒绝访问子目录时出现 500 服务器错误
【发布时间】:2015-08-31 04:00:19
【问题描述】:

我正在尝试使用 .htaccess 拒绝对子目录的直接访问:

# Deny direct access
<Directory "/cron">
  Deny from all
</Directory>

上面的代码在我的public_html目录的.htaccess文件中。我试图阻止的子目录位于 public_html/cron。

当我直接在浏览器中输入 /cron 文件夹中的地址时,我收到 500 服务器错误而不是 403。知道为什么吗?

【问题讨论】:

  • 不,但是当你得到 500 时,你的 apache 错误日志可以告诉你出了什么问题
  • @michael 我刚刚检查了错误日志,上面写着&lt;Directory not allowed here

标签: .htaccess


【解决方案1】:

您不能在.htaccess 文件中使用&lt;Directory&gt;。

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

上下文:服务器配置、虚拟主机

在您的/cron/.htaccessfile 中使用:

deny from all

【讨论】:

    猜你喜欢
    • 2019-09-06
    • 2018-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-27
    • 2019-10-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多