【问题标题】:Exclude directory from mod_autoindex.c Options -Indexes从 mod_autoindex.c 选项中排除目录 -Indexes
【发布时间】:2016-01-27 02:39:43
【问题描述】:

我的 .htaccess 中有以下内容:

# "-Indexes" will have Apache block users from browsing folders without a
# default document Usually you should leave this activated, because you
# shouldn't allow everybody to surf through every folder on your server (which
# includes rather private places like CMS system folders).
<IfModule mod_autoindex.c>
  Options -Indexes
</IfModule>

但是,我有一个没有索引文件的目录(我更喜欢这样保存),我需要启用访问。如何从上面的代码中排除这个目录?

【问题讨论】:

  • 我的回答解决了你的问题吗?如果是这样,如果您能将其标记为已接受和/或支持它,我将不胜感激,这样我就可以得到信任,并且将来阅读本文的其他人会看到它解决了它。谢谢

标签: .htaccess mod-autoindex


【解决方案1】:

在该目录中创建一个 .htaccess 文件,并在其中放入以下内容

<IfModule mod_autoindex.c>
  Options +Indexes
</IfModule>

【讨论】:

    【解决方案2】:

    尽管有以下评论(我从其他人那里得到此代码):

    # "-Indexes" will have Apache block users from browsing folders without a
    # default document
    

    ...此代码不会阻止用户访问没有索引文件的目录中的文件。因此,我不需要从上面的代码中排除我的目录。

    例如,example.com/testdir 没有索引文件。但是,我可以访问 example.com/testdir/testfile.txt

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-17
      • 2013-06-10
      • 2014-11-28
      • 1970-01-01
      • 2011-11-21
      • 2016-12-18
      • 1970-01-01
      相关资源
      最近更新 更多