Disabling directory listings using .htaccess

By default when accessing any directory which does not contain an index file (ex: https://yourdomain.com/images/) a directory listing will be shown displaying a list of the files in that folder. Simply adding a blank/0 byte text file named "index.html" will prevent this directory list from being displayed, however another way to disable directory listings is by adding the following line to the .htaccess file in your public_html folder:

Options -Indexes

That's it, with this line in place folders which do not contain index files will no longer show the default directory list.

Was this answer helpful?

 Print this Article

Also Read

Redirection using .htaccess

Most websites are constantly changing "works in progress" and as one updates, rearranges and...

How to create a user-friendly URL using .htaccess?

If your website is using a long URL like example.com/files/folder/sitemap.html, you can change it...

Modifying existing .htaccess files

To modify/add directives to the .htaccess file in your public_html directory using "File...

Setting a default index page using .htaccess

By default our servers will look for (in order) a file by the name of index.html, index.cgi,...

Creating custom error pages using .htaccess

One of the many things one can do to make their website a little more professional-looking is to...