Enabling/disabling directory listings using .htaccess

By default when accessing any directory which does not contain an index file on a cPanel server (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.

On DirectAdmin servers, directories which do not contain an index file will display a "403 Forbidden" message by default. To enable the directory listing feature you will want to add the following line of code to the .htaccess file in your public_html folder:

Options +Indexes

  • 5 Kasutajad peavad seda kasulikuks
Kas see vastus oli kasulik?

Seotud artiklid

How to redirect a page to another page or website using .htaccess?

If a page on your website no longer exists and you want to redirect it to your new page or...

Redirection using .htaccess

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

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,...

Directory protection using .htaccess

One of the more common/popular uses of .htaccess is to password protect specific directories...

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...