从 mod_autoindex.c 选项中排除目录 -索引



我的.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 文件,并在其中放置以下内容

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

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

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

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

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

最新更新