2 methods to prevent a Web site from displaying a list of file directories (htaccess) _linux

Source: Internet
Author: User
Tags cpanel

The Web site file directory listing is similar to the following figure, such as the display, this effect, by default, can be displayed, the new host can be purchased by default in the form of a list of files displayed:


Index Manager

The index Manager allows you to customize the way you view directories on the network. You can choose the default style, no index, or two types of indexes. If you don't want people to see the files in your directory, select No index.
But there are a lot of children's shoes (including me) do not like their own blog to display a list of directories, here are two ways to solve the problem (the same principle):

method One: Modify. htaccess file

Locate the. htaccess file in the root directory of the space web site, where the space path is generally/home/youusername/public_html/, adding this code to the. htaccess file at the end of the line.

Copy Code code as follows:

Options all-indexes

Save the exit, if you are using FTP, modify the save and upload again.

Method Two: Cpanel Admin Interface "Index Manager" Modify

Log on to cpanel, and then pull to the "advanced"-"Index manager" below

Please click the folder name to select the folder you want to protect.

Select No index, and then save.

All of the above two methods can be used to prohibit the Web site to display a list of file directories, but if carefully studied, the second method of operation is also in the. htaccess this file adds the code.

Copy Code code as follows:

Options all-indexes

However, the first method is recommended because the code must be independent of one row, and the default of the Index manager action in Cpanel is also added to the. htaccess file, but there is no word wrapping, if there is already content in the file, The modified result will become the options All-indexes added to the end of the last sentence, not a new line, resulting in a Web site error, inaccessible. I just changed my face to this problem. Finally, the first method is used to modify the success.

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.