How to disable Directory Listing using .htaccess

bardimin pic

Written by Bardimin

On March 4, 2022
Home » Blogs » Framework » How to disable Directory Listing using .htaccess

Directory Listing allows your website visitors to get a complete list of all the files and folders that live on your site. The will display all the contents of the directory if you do not create an “index.html” file in that directory.

Protecting your directory by preventing or disabling Directory Listing from your website visitors will increase the of your website. At least it will make it difficult for people who intend to find holes on your website.

If you do not protect the directory that you create when someone accesses the directory, it will appear as follows.

directory-listing-01

You can see all the contents of the directory will appear in the . To protect it, you can add an empty “ index.html ” file in each directory you create.

Another way is to add the file “ .htaccess ” to the root of your website. You can create the file with and add the following code to the “. “.

Options All –Indexes

Internal Error message will appear in the browser, as shown in the following image.

directory-listing-02

The next method is still using the “. ” and you add the following code

IndexIgnore *

The display in the browser will display as if the directory does not contain any files, as shown below.

directory-listing-03

You can choose the method of protection that you think is suitable for your needs and combine it with other methods and techniques to protect your website.

Latest Articles

Basic Computer and Laptop Maintenance Techniques

Basic Computer and Laptop Maintenance Techniques

You may not realize it, but computers and cars have something in common, both requiring regular maintenance. If your car needs regular oil changes, your computer should also regularly update its software, keep its antivirus up to date, and check for spyware....

The desktop version of ChatGPT for Windows, Linux, and Mac

The desktop version of ChatGPT for Windows, Linux, and Mac

Do you know what ChatGPT is? Do you know how to get and install ChatGPT on your device? ChatGPT is fast becoming one of the most important inventions in the world of natural language processing. You can use it to generate human-like responses based on your input. You...

24 Pinout Voltage at ATX Power Supply to the Motherboard

24 Pinout Voltage at ATX Power Supply to the Motherboard

The Power Supply converts alternating current (AC) power into low-voltage controlled direct current (DC). Some Power Supply devices include a choice of manual input voltages, while others automatically adjust. The Power Supply converts the voltage from the power line...

Google Chrome – Open Bookmarks to a New Tab By Default

Google Chrome – Open Bookmarks to a New Tab By Default

Bookmarks are shortcuts to open website pages that you have saved for you to visit again later. Have you ever visited a website page that is quite interesting and you want to visit it again later? Considering the address of a website page is certainly difficult,...

x