How to Hide and Show “Index Of” on your Website

You may have visited one of your web page’s URLs and found a list of files like the one included in this post? It can be embarrassing and also pose a security threat to your website. The reason behind this output/display is that if you create a new directory (or folder) on your website, and do not put an “index.html” file in it, you may be surprised to find that your visitors can get a directory listing of all the files in that folder. For example, if you create a folder called “incoming”, you can see everything in that directory simply by typing “http://www.example.com/incoming/” in your browser. No password or anything is needed.

In this article, you can configure your web server so that it does not show a directory listing by default.

Many people today are building their own websites for some reason. Many build websites for a simple online brochure and some are for online stores. That is not bad though. Your website is one of the important factors in your business. So whether you are building it as a simple online brochure or an online store, setting it up in a proper way it is somewhat like as important as naming your own child. So it is just a nice move to invest time in setting up your website properly.

Before we get into the technical side of things, here are some definitions to digest;

Web Server

According to Mozilla Developer Network, The term web server can refer to hardware or software, or both of them working together.

Check out >>>  The Difference between Adware, Spyware, and Anti-virus

On the hardware side, a web server is a computer that stores web server software and a website’s component files. (for example, HTML documents, images, CSS stylesheets, and JavaScript files) A web server connects to the Internet and supports physical data interchange with other devices connected to the web.
On the software side, a web server includes several parts that control how web users access hosted files. At a minimum, this is an HTTP server. An HTTP server is a software that understands URLs (web addresses) and HTTP (the protocol your browser uses to view webpages). An HTTP server can be accessed through the domain names of the websites it stores, and it delivers the content of these hosted websites to the end user’s device.
At the most basic level, whenever a browser needs a file that is hosted on a web server, the browser requests the file via HTTP. When the request reaches the correct (hardware) web server, the (software) HTTP server accepts the request, finds the requested document, and sends it back to the browser, also through HTTP. (If the server doesn’t find the requested document, it returns a 404 response instead.)

.htaccess

.htaccess files provide a way to make configuration changes on a per-directory basis on a web server

To hide/show your directory:

Via Web Hosting Account

  1. Log in to the Control Panel of your Website Hosting plan
  2. Click File Manager in the File Section
  3. Click public_html
  4. Check for .htaccess, If it does not exist, make sure that it is not hidden from your view.
  5. If it is hidden check the top right-hand corner for the settings icon, to reveal “show hidden files” or some such thing, make sure you enable it.
  6. Make a Backup of the .htaccess File by downloading it to your computer to make sure you have two(2) copies of the .htaccess file, the one you are about to modify, and a pristine copy of the original. The backup is useful in case you accidentally make an error later.
  7. If you’ve managed to get the .htaccess file, search for the edit option and navigate to the editor (eg an ASCII text editor).
  8. Add the following line to your .htaccess file.
Options -Indexes

Whenever you modify your .htaccess file, you should always check that your website still works after uploading it. It is very important to note that the .htaccess can make or ruin your website and should be used with caution.

Check out >>>  The Difference between Adware, Spyware, and Anti-virus

If anything goes wrong, delete the .htaccess file on your website and your site should work again. For those who had an existing .htaccess on the site before, upload the backup copy to the site. If all goes well, you should get a “Forbidden” error or some error reminding you that you don’t have access to view such resources.

If you enjoyed this piece and would like to share your thoughts, I would be glad to reply your comments.

Leave a Reply

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

Scroll to Top