In general, many virtual host presets are not open to protect the site host directory files, in fact, it is very dangerous, if you forget to place the index file in the directory, it is likely that your directory is seen light, a careless very likely important information is taken away, this is quite serious one thing. If it is a Linux host, we can use the simple. htaccess syntax to protect the files in the site host directory so that others cannot easily see them.
Usually we use the simplest way to protect the directory, than to use "index.php", "index.html" and so on, such as the site index file, because the host preset settings in the directory is the default is to catch the index file, and the index file will usually have many kinds, The main opportunity to continue to arrange the crawl, so you can set the index file to allow the host to crawl, to achieve the effect of protecting the directory. But if the host needs the index file does not exist, this time the host will directly display the contents of the directory, because the host does not know who to crawl as the main page, so it will be all displayed.
Although it is possible to use the index file to protect the directory, it is tiring to pass an index file for each subdirectory, and we can use ".htaccess" to batch it.
Options-indexes
Advanced use of grammar
Of course, the syntax has other related purposes, the following are a few simple items for your reference, if you think the following syntax is not you want or want to learn more, you can go to the official Apache website to see the English manual, see what else about " Indexoptions"'s use or other good features Oh!
- Options +indexes: Show all files in the directory
- Options-indexes: Hide all Files under directory (already described above)
- Indexoptions +fancyindexing: Displays all files in the directory, small icons with file types in front of the files
- Indexoptions-fancyindexing: Displays all files in the directory but does not contain a small icon of the file type
- Indexignore *.php *.exe: Hide specific files, the rest of the files are displayed normally (Hide all PHP and EXE files)
Reprinted from: http://www.sjyhome.com/htaccess/protecting-the-directory-and-file.html
. htaccess Protecting directories and files