How To Restrict Access To A Folder With Htaccess?

download.png

Hi,

In this tutorial, you will learn how to restrict access to a folder with htaccess. We will use htaccess deny access to folder. I would like to share with you how to deny access to directory htaccess. you can see how to deny access to a folder htaccess. Follow bellow tutorial step of htaccess deny access to directory.

In this post, i will show you some ways how to restrict access to directory with .htaccess file. sometime we have public directory with images and visitor can access full directory with folder path, but we can prevent this. so let's see some example and you can do it your own:

Example 1:

you can not access public directory.

.htaccess
RewriteEngine On
RewriteRule (^|/)public(/|$) - [F]
Example 2:

you can not access any directory of your app.

.htaccess
# directory browsing
Options All -Indexes
Example 3:

you can not access public directory.

.htaccess

  Order allow,deny
  Deny from all

I Hope It Can Help You...