When you enter the address in the browser:
http://localhost:8080/
If there is a index.html in your file root directory, the browser will display the contents of the index.html, if no index.html,apache will display the directory list of the file root directory in the browser, and the directory list includes files and subdirectories under the root directory of the file. Poses a security risk to the site.
Also when you enter the address of a virtual directory:
http://localhost:8080/My/
If there is no index.html in the virtual directory, the browser also displays the directory structure of the virtual directory, listing the files and subdirectories under the virtual directory.
We can prevent Apache from displaying the list of directory structures by modifying the Apache configuration file.
Open httpd.conf to see a directory configuration:
<directory "D:/wamp/www" >
Options Indexes FollowSymLinks
AllowOverride None
Order Allow,deny
Allow from all
</Directory>
You just need to remove the Indexes from the red code above, and you can prevent Apache from displaying the directory structure. Users will not see the list of files and subdirectories in the directory.
The function of Indexes is to display the directory structure when there is no index.html file in the directory.
has been replaced by the following:
<directory "D:/wamp/www" >
Options FollowSymLinks
AllowOverride None
Order Allow,deny
Allow from all
</Directory>
Alternatively, you can also prevent Apache from displaying the directory structure by adding a minus sign "-" in front of the Indexes.
"+" in front of the indexes to allow directory browsing, plus "-" means to prevent directory browsing. Modified as follows:
<directory "D:/wamp/www" >
Options-indexes FollowSymLinks
AllowOverride None
Order Allow,deny
Allow from all
</Directory>