← Back to Security & SSL

How to Disable Directory Listing

Directory listing shows all files in a folder when no index file exists β€” a security risk that exposes your site structure and sensitive files to the public.

Disabling Directory Listing via .htaccess

Add this line to your public_html/.htaccess:

Options -Indexes

This prevents Apache from showing directory contents. Visitors trying to access a folder without an index file will see a 403 Forbidden error instead.

Disabling for a Specific Folder

Create a .htaccess file inside the specific directory with the same Options -Indexes line. This limits the effect to that folder and its subdirectories.

Was this article helpful?

On This Page