Apache controls whether the site directory of recommendations are displayed

  • 2020-05-14 05:44:44
  • OfStack

Load the mod_autoindex module

In version 2.4 of Apache, the mod_autoindex module is required to control whether the site directory is displayed. Without this module, the directive to display the site directory is invalid.

Load the module

LoadModule autoindex_module modules/mod_autoindex.so

Method 1

Resolution process: first, check the official website documents of apache, and cannot find the required parts quickly. Search the "apache display site directory" search engine, find the relevant information, similar. The configuration following the data instructions is invalid.

Start trying the configuration in the virtual host and non-virtual host try data, still invalid. Then go back to the official website to search for the key words "Options Indexes" and see "mod_autoindex can generate a listing of the directory contents".

httpd.conf then retrieves the full text and realizes that the module is not loaded.

The virtual host displays the site directory

apache 2.4 does not display the site directory by default. The virtual host is configured as follows:


<VirtualHost *:80>
ServerAdmin chuganghong@qq.com
DocumentRoot "E:\wamp64\www\my-site\test-php"
ServerName test-php.com
ErrorLog "logs/test-php.com-error.log"
CustomLog "logs/test-php.com-access.log" common
</VirtualHost>

Add the instruction Options +Indexes to display the site directory, the complete code is as follows:


<VirtualHost *:80>
<Directory "E:\wamp64\www\my-site\test-php">
Options +Indexes #  Display site directory 
</Directory>
ServerAdmin chuganghong@qq.com
DocumentRoot "E:\wamp64\www\my-site\test-php"
ServerName test-php.com
ErrorLog "logs/test-php.com-error.log"
CustomLog "logs/test-php.com-access.log" common
</VirtualHost>

Options +Indexes or Options Indexes or without this directive, displays the site directory.

Options-Indexes, site directory is not allowed.


Related articles: