How to disable directory browsing using htaccess?


For security reasons, it is highly recommended to disable directory browsing on your website. This prevents visitors from viewing the contents of your website’s directories, which can help protect sensitive files and improve your site’s overall security.

To disable directory browsing, add the following line to your .htaccess file, which is typically located in the root directory of your website:

Options -Indexes
  • If you do not see a .htaccess file, you may need to enable the option to show hidden files in your file manager or FTP client.
  • After adding the line above, save the file. Directory listings will now be disabled, and visitors will receive a 403 Forbidden error if they try to access a directory without an index file.
  • Always back up your .htaccess file before making changes, as incorrect syntax can affect your website’s functionality.

Note: If you are using WordPress or another CMS, your .htaccess file may already contain important rules. Be careful not to overwrite existing content.


Was this answer helpful?

One email a month. Endless business benefits.

Don't miss out on WMTWWFY — the newsletter that keeps your website fast, safe, and visible.

« Back
Spinner
aluminium-anthropoid Security Check