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

时间:2016-01-18 17:42:00

标签: .htaccess mod-autoindex

我的.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>

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

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:0)

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

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

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

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

相关问题