The IndexIgnore
directive is a pattern where files in a directory that has Indexes
turned on won't show up in the auto-index if they match the pattern.
Say for example, we have a directory, foo
, and inside that directory, we have an .htaccess
file, and 3 files, a
, b
, and c
.
If in the htaccess file there is Options -Indexes
, then by going to http://mysite.com/foo/
, I will get a 403 Forbidden response, because there is no index file (index.html, index.php, etc) and auto-index is turned off via -Indexes
.
If in the htaccess file there is IndexIgnore b
, then by going to http://mysite.com/foo/
, I will get an auto-index response listing the files, a
and c
. The b
file will be missing because it has been ignored. If we have IndexIgnore *
in the htaccess file instead, and we go to http://mysite.com/foo/
, we'll get an auto-index file that is blank, since all files have been ignored.
As for which is better, it depends on what you want. They do fundamentally two different things. Do you want auto-indexes? If not, turn it off Options -Indexes
. If so, leave it on. If you don't want some things to show up in an auto-index, then use IndexIgnore
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…