Search Our Database

How To Enable/Disable Directory Listing Using .htaccess

Last updated on |
by

When accessing any directory (example: http://yourdomain.com/images/) that does not have an index file, all the available folders and files in that directory will be shown.

To enable directory listing, you need to add a line of code into .htaccess and place it in your public_html folder.

 

Step 1: Login into your web server via SSH.

 

Step 2: Type and execute the following command:

vi  .htaccess

 

Step 3: Type the following code into the text file.

Options +Indexes

 

Step 4: Save and exit.

 

Step 5: Try accessing any of your site’s directory and it should list out all the available folders and files in that directory.

allow-directory-listing-htaccess1

 

Step 6: You can disable the feature by replacing the code in step 3 with the one below, and repeat the tutorial.

Options +Indexes

 

Step 7: Forbidden Access or 403 Error will now be displayed when a user tries to access a directory without an index file.

403-directory-listing-error-htaccess