Mobile app version of vmapp.org
Login or Join
Karen161

: "Require valid-user" in "" section of .htaccess not password protecting directory I am trying to lock a folder called locked with the encrypted user passwords stored in .htpasswd. This does

@Karen161

Posted in: #Apache #Htaccess

I am trying to lock a folder called locked with the encrypted user passwords stored in .htpasswd. This does not work:

AuthUserFile /srv/http/.htpasswd
AuthType Basic
AuthName "Login Required"
<Files "locked" >
Require valid-user
</Files>

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Karen161

1 Comments

Sorted by latest first Latest Oldest Best

 

@Speyer207

<Files> is designed for specifying files, not directories. E.g:

<Files admin.php>
deny from all
</Files>


Use one of the following:


<DirectoryMatch>
<Directory>
<Location>
<LocationMatch>


But it should be noted that you must have mod_setenvif and mod_auth enabled, virtual host with AllowOverride AuthConfig and take note that <location> and <LocationMatch> only work in the virtual host configuration, i.e /sites-enabled/example.conf.

But there is a much easier way than any of the above...

Simple create another .htaccess file in the directory you want to protect:

AuthName "restricted stuff"
AuthType Basic
AuthUserFile /usr/local/etc/httpd/users
require valid-user*

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme