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.
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.
9 Comments
It has worked thanks, I’m so happy that i have been able to do this.
thanks man useful post for new apache users
very helpful , useful for new apache installation
thanks For Help
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.
EG’s comment works for me. Removing the word ‘Indexes’
Thanks, working for me.
This isn’t working for me.
Thank you, working in Ubuntu server 16