【问题标题】:.htaccess directory internal server error [duplicate].htaccess 目录内部服务器错误 [重复]
【发布时间】:2021-12-21 14:17:10
【问题描述】:

在我的本地主机上,我使用 php 内置服务器,并希望阻止某些目录。

<Directory /config/>
    Options +Indexes
    IndexOptions +FancyIndexing
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Directory>

但是在我的 debian apache2 服务器上,我得到了一个内部服务器错误。 Apache2错误日志:

[Tue Dec 21 08:38:31.577748 2021] [core:alert] [pid 30883] [client xxx:42012] /var/www/html/.htaccess: <Directory not allowed here

【问题讨论】:

  • 但是我如何在我的例子中应用这个?我必须将测试更改为配置吗?
  • 把它放到正确的配置文件中,而不是.htaccess
  • 在 htaccess 文件中不能使用 Directory 指令。

标签: php .htaccess


【解决方案1】:

在我使用的 apache2.conf 中

<Directory /var/www/html/config/>
        Options +Indexes
        IndexOptions +FancyIndexing
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1

【讨论】:

  • 你应该这样做。 /html/ 用于提供公共页面。 如果你有配置,不要把它放在公共目录中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-05
  • 1970-01-01
  • 2014-10-31
  • 2016-07-16
  • 1970-01-01
  • 1970-01-01
  • 2016-09-22
相关资源
最近更新 更多