• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How To Disable Directory Listing in Apache

Written by Rahul, Updated on April 30, 2020

The default indexing is enabled in Apache web server using the Options +Indexes or Options Indexes directive. Generally, this happens, when there is no index (default) file is available in the directory. Then Apache doesn’t understand, which file to display on page and list all files on-page. You can see the below screenshot as there is no index file available.

Directory Listing in Apache

Disable Directory Listing in Apache

To disable the directory listing for a specific directory, add the following settings in Apache Virtual Host or create a .htaccess file in that directory with below content. The Options -Indexes disabled the listing of files on the website if an index file is missing.

In Apache Virtual Host:

1
2
3
<Directory /var/www/public_html>
      Options -Indexes
</Directory>

In .htaccess file:

1
Options -Indexes

While using the .htaccess, make sure that Apache server is enabled to use .htaccess files for that directory. In most cases, .htaccess is disabled by default.

Finally, reload the Apache service after doing changes in Virtual host to apply changes. The .htaccess changes will apply immediately without reloading service.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

8 Comments

  1. Avatar Rahul Gehlaut Reply
    January 6, 2021 at 4:18 pm

    thanks man useful post for new apache users

  2. Avatar tyson Reply
    August 6, 2020 at 9:39 am

    very helpful , useful for new apache installation

  3. Avatar Harsh Reply
    July 15, 2020 at 3:20 am

    thanks For Help

  4. Avatar EG Reply
    July 2, 2020 at 7:07 pm

    I got it working by removing Indexes out of my httpd.conf file.

    It may look something like this “Options Includes Indexes FollowSymLinks MultiViews” and just remove the word indexes and restart the apache service.

    I am using XAMPP for Windows and it works the same since it is Apache config and not an OS config.

    • Avatar Johan Reply
      July 28, 2020 at 5:51 pm

      EG’s comment works for me. Removing the word ‘Indexes’

  5. Avatar Borislav Reply
    April 29, 2020 at 8:44 pm

    Thanks, working for me.

  6. Avatar Cool Reply
    October 25, 2019 at 3:16 pm

    This isn’t working for me.

  7. Avatar Wilton Reply
    September 25, 2019 at 4:07 pm

    Thank you, working in Ubuntu server 16

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How To Install Python 3.9 on Ubuntu 18.04 0
  • How to Use AppImage on Linux (Beginner Guide) 2
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy