The DirectoryIndex directives allow us to specify which page is displayed when a directory is accessed by visitors. We can also disable and enable the directory indexing with the help of directives.

In this article, We will learn how to enable or disable the directory content indexing, on the apache server.

What is directory indexing?

When we have no index file at the root of any directory, the visitors view the files list in the absence of an index file like index.php, index.html, etc. It is not good from the perspective of security. Hackers can view files that exist on our server and use them to inject malware onto our website. So it is a good idea to disable the directory indexing for tightening the security.

Enable directory index listings in htaccess

We can enable the index listing by adding the following line to the .htaccess file:

Options +Indexes

Disable directory index listings in htaccess

We can disable the index listing by adding the following line to the htaccess file:

Options -Indexes

All done.

 

 

 

 

 

better(comparative and superlative of ‘well’) wiser or more advantageous and hence advisableMore (Definitions, Synonyms, Translation)

 

 

 

Pin It on Pinterest

Shares
Share This