Apache Stop Directory Listing

Today We are going to talk about how to Stop directory listing on Apache Web Server, In this post, I used my subdomain apache.hacknos.com in your case few things are different Like Domain Name, Apache VirtualHost File, and Document Root Directory.

Apache Stop Directory Listing Related Posts

  1. Apache Server Password Protected
  2. Free SSL For Apache Server Website
  3. Apache Stop Directory Listing
  4. Joomla Install on Apache Server
  5. Apache Stop Directory Listing On Ubuntu Server

In Apache Web Server, directory listing is a default option that displays the contents of a directory if there is already have any indexing file Such as Index.php or index.html, so your content didn’t display to any user if there is no indexing file your content is displayed publicly.

What are directory listing

Let’s check how to display files and directories on Apache Server, navigate your Website URL and you can saw your Server Files.

Disabling Directory Listing on Apache Web Server

There are two ways to disable Apache Directory listing On Apache Server, If you’re using the default configuration host file ( 000-default.conf ) for Apache Web-server you need to edit your Apache2 configuration file.

How do I stop directory listing in Apache

Let’s open the file on your text editor.

And find this default code on your apache2.conf file

Change this line

to this line

and restart your Apache2 Service run the command

Apache Disable Directory Listing Using Virtualhost

The Second Option is to disable directory listing using a Virtualhost conf file, If you’re setup multiple websites on a single Server like me, so we need to edit our virtual host file.

in my case, my Apache Virtualhost configuration file name is ( apache.hacknos.com.conf ) in your case your configuration file name is different.

let’s open this file in any editor.

And Add this code to your Virtualhost configuration file.

The next step is to go to your Document-Root Directory and Create a file .htaccess and Add this code ( Options -Indexes” on your .htaccess file.

And reload your Apache2 Service

Apache Stop Directory Listing Successfully Disable

Again open your browser and navigate your Website URL and We saw Forbidden Resource Error. It’s mean our configuration is successfully complete.

  • How do I stop directory listing in Apache,
  • How do I turn off directory listing
  • How do I restrict access to Apache Directory
  • Where can I find .htaccess file in Apache
  • Where do I put .htaccess file
  • What is Apache FollowSymLinks
  • How do I create a .htaccess file

How do I restrict access to Apache Directory

If you want to Restrict the directory on Apache Server follow these steps. An example I have a Private Name Directory and I want to restrict it to Access Publicly.

Let’s connect with your ssh service and run the add a user command for password Authentication in the Private Directory.

( -c ) where You want to Save .htpasswd File You can choose any location for this File.

After creating our new user and password for the private directory we move to the next step Let’s open your Apache configuration file in any editor. if you’re using Apache Virtual-host File in your case your virtual-host file name is different.

And Add this code to your virtual-host file

After Insert the code on your Virtual-host file your file looks like this image. edit the configuration code you according.

Go to your Private Directory and Create a .htaccess File

and add this code on your .htaccess file and restart your Apache2 Service and Reload Your Private Directory.

More Related Post Apache Stop Directory Listing

  1. File Transfer Using Apache Server
  2. Apache VirtualHost Overview
  3. Apache Stop Directory Listing
  4. Onion Dark Web Website Host on Apache Server
  5. Disable Directory listing
Where can I find the .htaccess file in Apache

You can locate your .htaccess file in your Document Root Directory, but it’s hidden you can visible the file by changing your Setting.

Where do I put .htaccess file

You can place your .htaccess file in your Document Root Directory. but in some cases, you put the .htaccess in a file in another directory.

Apache FollowSymLinks use for Creating a symlink file and Directory to pointing to your webroot.

Exit mobile version