Disable Directory Browsing with .htaccess Print

  • 0

This article applies to Apache based web hosting accounts. Directory browsing controls whether a visitor who opens a folder without an index file sees a list of the files in that folder. You can disable these listings with an .htaccess file.

Disable directory listings

Add the following line to the .htaccess file in your document root, or in the specific folder you want to protect:

Options -Indexes

The setting applies to that folder and its subfolders. Save the file and open the folder in your browser to confirm the file list no longer appears.

If you get a 500 error or nothing changes

A 500 error, or no visible change, can mean the configuration of your service does not permit the Options directive in .htaccess files. In that case:

  • Remove the line you added and save the file.
  • Confirm the website loads normally again.
  • Open a support ticket and ask support to disable directory browsing for the folder.

Do not experiment with other server directives in .htaccess. Incorrect directives can take the whole site offline.

About enabling listings

Options +Indexes enables directory listings. Do not use it unless you deliberately want visitors to see the file names in a folder that has no index page.


Was this answer helpful?

« Back

WHOIS Information

×
Loading WHOIS information...