Skip to content

How To Prevent Directory Browsing With .htaccess

Sometimes a viewer of your website can change a few characters in the URL of your site and continue to browse your directories. It sounds fun but could be very dangerous for your website. It’s called directory browsing.

I will recommend you to prevent/disable directory browsing on your website. Just add following snippet to your .htaccess file and save it:

# directory browsing
Options All -Indexes

If you wanna to enable directory browsing on some particular directory just add the following snippet:

<Directory /www/somefolder>
    Options Indexes FollowSymLinks
    AllowOverride None
</Directory>

Leave a Reply

Your email address will not be published. Required fields are marked *