How to disable directory listing for specific directories in Apache?
by n00b_noob from LinuxQuestions.org on (#5AGEZ)
Hello,
I'm using CentOS 8 x86_64 and my server hosting a WordPress website. I scanned my WordPress website with a security scanner and it found some vulnerabilities about directory listing. Some lines of my Virtual Host file are:
Code:<Directory "/var/www/WP">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>Some of my WordPress directories are browsable and when I open the URLs, then the content of the directories displayed:
Code:https://example.net/wp-content/plugins/email-subscribers/
https://example.net/wp-content/plugins/contact-form-7/How can I disable the directory indexing for those directories? I added below lines to my Virtual Host config file, but not worked:
Code:<Directory /var/www/WP/wp-content/plugins/email-subscribers>
Options -Indexes
</Directory>
<Directory /var/www/WP/wp-content/plugins/contact-form-7>
Options -Indexes
</Directory>I also did:
Code:<Directory "/var/www/WP">
Options -Indexes +FollowSymLinks
AllowOverride all
Require all granted
</Directory>But not matter. How can I solve it?
Thank you.


I'm using CentOS 8 x86_64 and my server hosting a WordPress website. I scanned my WordPress website with a security scanner and it found some vulnerabilities about directory listing. Some lines of my Virtual Host file are:
Code:<Directory "/var/www/WP">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>Some of my WordPress directories are browsable and when I open the URLs, then the content of the directories displayed:
Code:https://example.net/wp-content/plugins/email-subscribers/
https://example.net/wp-content/plugins/contact-form-7/How can I disable the directory indexing for those directories? I added below lines to my Virtual Host config file, but not worked:
Code:<Directory /var/www/WP/wp-content/plugins/email-subscribers>
Options -Indexes
</Directory>
<Directory /var/www/WP/wp-content/plugins/contact-form-7>
Options -Indexes
</Directory>I also did:
Code:<Directory "/var/www/WP">
Options -Indexes +FollowSymLinks
AllowOverride all
Require all granted
</Directory>But not matter. How can I solve it?
Thank you.