How to disable directory browsing using .htaccess
Evans
Last Update 2 måneder siden
For security purposes, we recommend that you disable directory browsing on your website so no one can see the files/folders of your website.
You can disable Directory Browsing by adding this line to your .htaccess file.
What the code above does:
When someone visits a directory on your site that does not have an index file (index.html, index.php, etc.), instead of seeing a list of files, they will see a 403 Forbidden error or a blank page (depending on server config).
If you're managing a website on Apache (cPanel or DirectAdmin with Apache), placing this in your .htaccess file at the root of your site is the recommended way to prevent unwanted file listing.