htaccess deny direct access to folder | use of htaccess file

htaccess deny direct access to folder in website

Last Updated by Monika Dadool 11-Mar-20

0 7462

Anybody can open your folder directly by writing folder name such as images, JS and CSS along with URL Link and steal all files from that folder.

i.e. If you enter image folder name with URL Link, it will display all the files inside that image folder.

Such as:

Through the above example, anyone can display entire files on CSS or image folders.

How to prevent this?

By adding just two lines code in htaccess file, we can be prevent direct access of any folder.

Steps to deny direct access through .htaccess

1. Create. htaccess file on the website.

you just need to copy and paste the following simple code in your htaccess file.

# directory browsing
Options All -Indexes
htaccess deny direct access to folder in website

2. Save it. This will never permit users to open files directly.


htaccess deny direct access to folder in website

What is .htaccess?

.htaccess acts as a configuration file that permits configuration modifications on a per-directory basis.

Now the question is how we can block direct access to folders?

The exact answer is through .htaccess.

Do you think there are other concepts that I may include in this blog? Share with me through the comment box below !

I would love to hear from you!

Also, don't forget to like this post and share it with your peers!

How can I redirect URLs with htaccess


Leave a Reply

    Waiting for your comments