. htaccess Protecting directories and files

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.