By NewtownGuy
How do I configure apache2 so it will use htaccess files in each folder I want to protect ? Each folder represents a user and I want to configure each user separately and without having to modify the global httpd.conf file. I’ve placed the following into a .htaccess file in one folder, the name-1 folder, but I get the error message, “this web site does not require authentication” when I try to access the folder:
AuthType Basic
AuthUserFile /srv/auth/name-1/.htpasswd
AuthGroupFile /dev/null
AuthName "Enter user name and password, for demo cameras, enter demo and 12345"
Require valid-user
I’ve created the htpasswd file identified in line 2, and I’ve enabled htaccess in apache2.conf.
Note that I only want to protect certain folders, so some folders will be protected, but others, not. This all worked when I configured httpd.conf for each folder I wanted to protect, without using htaccess files, but stopped working when I switched to control via htaccess files in each folder.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
In order to use .htaccess files for Basic Authentication you will need to make sure that in your Apache configuration you’ve set AllowOverrride All. Check your virtualhost configuration in /etc/apache2/sites-enabled Without this setting, .htaccess files are not allowed to override default settings on a per directory basis.
Example:
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.