📣🌞🏖️🏄 Sunny Deals - Summer Sale! | Exclusive offers for Cloud Shared Hosting - 70% OFF | Starting from $3.99/mo

HostArmada Web Hosting Knowledge Base

Knowledge is power! Use that power and achieve total and unconditional control over the Web Hosting Services!

How can I prevent my files from being listed in the browser?

Directory listing is a function of the Apache webserver that displays the files inside a directory in your browser if there is no index file inside (index.php, index.html, index.htm, or index.js). To prevent this behavior, you should add the following snippet of code on the top of your .htaccess file:

Options -Indexes

The .htaccess file is located within the folder of the site for which you wish to prevent directory listing. For example, if you want to stop this behavior for your primary domain on a cPanel server, the rule has to be added within the .htaccess located here, however, please replace "user" with your actual cPanel username:

/home/user/public_html/

If the domain is as an addon domain, then please take a look at our article regarding locating the root directory of your domain name.

Another way you can disable/enable this function is described in our How to configure directory indexing in the cPanel tutorial.

As this is a straight out security breach, should a folder lack an index file, the majority of the users prefer not to display their data in the browser if they miss an index file. Because of that, we have decided to disable this globally on all our servers.

Was this article useful and on point?

Find out more about HostArmada entire range of optimized Web Hosting Services and take action today on improving your website Loading Speed, Security, and overall Stability!