Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htaccess and multiple htpasswd

I protected a couple of pages via the htaccess and htpasswd. Until now the site functioned well, but the last couple of days, we're experiencing some problems, and i wan't rule out this part of code.

My htaccess:

<Files "leiden.html">
 AuthName "Name and Password"
 AuthUserFile /var/www/fullpath to/.htpasswd
 Require valid-user
 AuthType Basic
</Files>

<Files "alkmaar.html">
 AuthName "Name and Password"
 AuthUserFile /var/www/fullpath to/.htpasswd2
 Require valid-user
 AuthType Basic
</Files>

<Files "vlaardingen.html">
 AuthName "Name and Password"
 AuthUserFile /var/www/fullpath to/.htpasswd3
 Require valid-user
 AuthType Basic
</Files>

ErrorDocument 401 /error401.html

And the corresponding htpasswd's containing the encrypted name and password combination.

.htpasswd

aaa:bbbb

.htpasswd2

ccc:dddd

.htpasswd3

eee:ffff    

Is it possible to use multiple htpasswd's in this way or is there a better/cleaner solution to use only one htaccess and only one htpasswd?

For some reason, the site regularly blocks a user's ip-adress as a safety-precaution and i want to rule this security-solution out as cause of the problem.

Thanx in advance. Melkman

like image 869
melkman Avatar asked Jan 25 '26 19:01

melkman


1 Answers

Is it possible to use multiple htpasswd's in this way or is there a better/cleaner solution to use only one htaccess and only one htpasswd?

Something that you could do is keep on htpasswd file, and instead of using Require valid-user, use the require with a specific username:

<Files "leiden.html">
 AuthName "Name and Password"
 AuthUserFile /var/www/fullpath to/.htpasswd
 Require user aaa
 AuthType Basic
</Files>

<Files "alkmaar.html">
 AuthName "Name and Password"
 AuthUserFile /var/www/fullpath to/.htpasswd
 Require user bbb
 AuthType Basic
</Files>

<Files "vlaardingen.html">
 AuthName "Name and Password"
 AuthUserFile /var/www/fullpath to/.htpasswd
 Require user ccc
 AuthType Basic
</Files>

The mod_authz stuff (htpasswd/BASIC auth) isn't what's causing IP addresses to be blocked. Something else must be causing that.

like image 176
Jon Lin Avatar answered Jan 27 '26 14:01

Jon Lin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!