First of all, if you don’t have a .htaccess file, take a look at this article to create one. You’ll need it for this tutorial.

If you don’t have an index file in every directory for your server, the contents of the directories are open for viewing. This can be a serious security issue. To remedy this, do the following:

Log in to your cPanel.
Then “File Manager” & choose the directory that the .htaccess file is in by clicking on the file icon
Click “Edit File” in the middle of the menu bar
Then just type the following into your .htaccess file in the public html directory:

Options -Indexes

That’s it!

There may be more settings you want to change with htaccess & Apache to improve security.

If you seek maximum performance and are an advanced user, edit the php.ini file and avoid htaccess.
Was this article helpful?
Thank you!