Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
683 views
in Technique[技术] by (71.8m points)

apache - IndexIgnore * or Options -Indexes

I've always used Options -Indexes to disable directory listing through .htaccess. However, I have seen people using IndexIgnore * instead. What's the difference? Which is better than the other?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...