How to disable directory indexes server wide

February 2, 2020 2 comments
How to disable directory indexes server wide

This is simply a feature that allows to view all files in a directory via a directory index when there is no index file in that directory.

By default Apache’s DirectoryIndexes value is turned on server wide. This allows the files in a folder to be viewed via a directory index when there is no index file present in that directory.

If you happen to have read our previous article on how to pass PCI compliance scans, leaving DirectoryIndexes on is a common way to fail a PCI scan. In this article we’ll walk you through disabling this server wide on your server, please note that this would require root access to your server.

  • Log into WHM
  • In the top-left Find box enter in Apache, then click on Apache Configuration.
  • Click on Global Configuration.Disable directory indexes server wide-step2-ashokkuikel
  • Scroll down to the Directory “/” Options section, then un-check Indexes.
  • Scroll down to the bottom of the page and click on Save.
  • Finally click on Rebuild Configuration and Restart Apache, Apache can take up to a few minutes to rebuild and during this time your websites won’t respond to requests.
  • You should see that Apache was successfully restarted now.

  • Now when you try to browse to a directory that doesn’t have an index file, you’ll receive an error instead of a directory listing.

    You should now know how to disable Apache’s DirectoryIndex setting server-wide on your server. This can help increase security by ensuring a directory that doesn’t include an index file isn’t exposing any other possibly sensitive files.

You can check our previous article; Steps to disable ‘Directory listing’ from CPanel.

Ashok kuikel

Ashok Kuikel is DevOps Engineer(Cloud Computing and Cyber Security), Entrepreneur working on Socio-Economic Development via Technology

He has been actively contributing as Joint Secretary of Federation of Computer Association of Nepal Kavre Chapter. Beside that, he is an official Global Peace Ambassador for Global Peace Chain, Nepal Chapter and Member of Internet Society, Nepal Chapter.

Above all, he enjoys learning about new trends and technologies and loves to share innovative ideas to contribute for the growth of the industry.

You can follow me on Social Media, GitHub, and via my Blog Channels.

2 responses to “How to disable directory indexes server wide”

  1. Manish Kuikel says:

Leave a Reply

Articles and Tutorials

We love writing about WordPress and latest plugins tutorials, WooCommerce stats, and much more.