How to disable Directory Listing using .htaccess

04 March 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.” file in that directory.

Protecting your directory by preventing or disabling Directory Listing from your website visitors will increase the security of your website. At least it will make it difficult for people who intend to find security 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 Notepad and add the following code to the “. “.

Options All –Indexes

Internal Server Error message will appear in the , 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.

Related Articles

File Sharing between Hyper-V Host and Guest

You can share files between hosts and guests on Hyper-V in the following ways. Hyper-V is a Microsoft hardware virtualization that allows you to create and run software versions of computers, called virtual machines. Each virtual machine acts like a full-fledged...

How to use voice typing to type on a PC

Tired of typing, you can use Voice Typing to type articles on a PC or laptop. Voice typing is one of the tools that can convert voice into writing. To use this feature, the PC or laptop you are using must have a microphone. You can use the voice typing feature to...