Would you like to learn how to disable the directory listing on the Apache server? In this tutorial, we are going to configure the Apache server to block the directory browsing feature.
• Ubuntu 20
• Ubuntu 19
• Ubuntu 18
• Apache 2.4.41
Copyright © 2018-2021 by Techexpert.tips.
All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means without the prior written permission of the publisher.
Equipment list
The following section presents the list of equipment used to create this tutorial.
As an Amazon Associate, I earn from qualifying purchases.
Apache – Related Tutorial:
On this page, we offer quick access to a list of tutorials related to Apache.
Tutorial Apache – Disable the directory listing
Install the Apache server.
Disable the Apache module responsible for the directory listing.
Restart the Apache service.
As a test, create a directory without an index file.
Try to access the directory without the index file.
Here is the command output.
In our example, the directory listing feature was disabled on the entire Apache server.
From a remote computer, open the browser and try to access a directory of the Apache server.
• http://192.168.2.222/test
The Apache server will display an error message.
Here is the result, before our configuration.
Here is the result, after our configuration.
Congratulations! You configured the Apache server to disable the directory browsing feature.
Tutorial Apache – Disable file listing on a specific directory
Install the Apache server.
Edit the Apache configuration file for the website.
Add the following lines to this configuration file.
Change the directory you want to protect.
Here is the file, before our configuration.
Here is the file, after our configuration.
Restart the Apache service.
As a test, create a directory without an index file.
Try to access the directory without the index file.
Here is the command output.
In our example, the directory listing feature was disabled on a directory.
From a remote computer, open the browser and try to access a directory of the Apache server.
• http://192.168.2.222/test
The Apache server will deny access and display an error message.
Here is the result, before our configuration.
Here is the result, after our configuration.
Congratulations! You disabled the directory listing on the Apache server.
Tutorial Apache – Disable directory listing using HTACCESS
Install the Apache server.
Edit the Apache configuration file.
Add the following lines at the end of the file.
Create an HTACCESS file on the website directory.
Add the following lines to this configuration file.
Configure the correct file permission.
Restart the Apache service.
As a test, create a directory without an index file.
Try to access the directory without the index file.
Here is the command output.
In our example, the directory listing feature was disabled on a directory.
From a remote computer, open the browser and try to access a directory of the Apache server.
• http://192.168.2.222/test
The Apache server will deny access and display an error message.
Here is the result, before our configuration.
Here is the result, after our configuration.
Congratulations! You disabled the directory listing on the Apache server.