: "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
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>
More posts by @Karen161
1 Comments
Sorted by latest first Latest Oldest Best
<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*
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.