How to disable the indexing of the 'icons' directory in your Apache HTTP Server
To disable indexing (directory listing) for a specific directory, such as the 'icons' directory in your Apache HTTP Server, you can use the Options directive along with the -Indexes
option in your Apache configuration. Here's how to do it:
1. Edit the Apache Configuration:
Open the Apache autoindex.conf file for editing. The location of this file can vary depending on your CentOS 7 setup, but it's commonly located at /etc/httpd/conf.d/
directory.
You can use a text editor like nano
or vi
to open the configuration file with root privileges:
2. Locate the Directory Block:
In your Apache configuration file, look for the <Directory>
block that corresponds to the 'icons' directory. It should look something like this:
<Directory>
Options Indexes MultiViews FollowSymlinks
AllowOverride None
Require all granted
</Directory>
3. Disable Indexing:
Inside the <Directory>
block, replace from "Options Indexes MultiViews FollowSymlinks
" to "Options MultiViews FollowSymlinks
" option to disable directory indexing:
<Directory>
#Options Indexes MultiViews FollowSymlinks
Options MultiViews FollowSymlinks
AllowOverride None
Require all granted
</Directory>
4. Restart Apache:
sudo systemctl restart httpd
After making changes to the Apache configuration, you need to restart Apache to apply the changes:
This command will restart the Apache HTTP server with the updated configuration.
Now, directory indexing should be disabled for the 'icons' directory, and users will see a "Forbidden" error when trying to access it via a web browser. Make sure to replace "/path/to/your/icons"
with the actual path to your 'icons' directory in the Apache configuration file.