Whenever you place files on your website without the presence of an index file in the main folder or subfolders, every visitor will be able to view the contents of your files.
Every time you visit a website, the web server will show you the content of that website. The web server will look for an index file, which makes sure the files and fodlers are displayed correctly. When the index file is missing, the web sever will show the files and folders in alphabetic order.
Considering the safety of your website, displaying all the files on your website is far from recommended. An example of a website that is missing the index file is shown below:
Always make sure there is an index file present in the folders that contain your website's files. Depending on the type of website, either an index.html or index.php file is used. This file will make sure the contents of the folder or subfolder are shown.
Adding an index file
When adding an index file, you can use an empty index.html or index.php file. You can add content to it as you wish. The most important part is that the file is present.
To make an index file, it is best to use a program that supports these types of files. We recommend to use Notepad++ for this because Notepad++ allows you to save 'empty' files.
Save the file using the name 'index' and choose .html or .php as the file type. You can use SFTP to upload it to the folder which is missing the index file. Your website will then show the content of the website instead of showing a list of files.
When you have installed WordPress on your hosting package, the index.php file will be created automatically in the correct folder. If you add a folder to your website, make sure you manually add an index file to it.
Use an .htaccess file
The alternative is to add the following line to an .htaccess file within the root folder or a subfolder.
# This will make sure pages without an index file are not shown Options -indexes
Adding this line will make sure all parts of your website that do not contain an index file are not shown. A message will be shown stating the subfolder is inaccessible. The content of the subfolders will still be shown when visiting the website.
In this article we have explained when your website shows a list of files and how to make sure it doesn't.