Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add multiple users for .htaccess

I have protected my website with .htaccess file with one user, script that i use in below

.htaccess :

ErrorDocument 401 "Unauthorized Access"
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
AuthType Basic
AuthName "domain-name.com"
AuthUserFile "/home/path/.htpasswds/domain-name/passwd"
require valid-user

passwd :

user1:password1

How to add multiple users? I have tried as below and not success.

user1:password1
user2:password2

Please assist me in this, thanks in advance

like image 622
dcthaju Avatar asked Oct 26 '25 08:10

dcthaju


1 Answers

First you need to create the htpasswd file in your home directory using the htpasswd command. SSH into your directory and enter:

htpasswd -c .htpasswd userone

Enter password for userone twice.

For multiple users, repeat the command without the -c

htpasswd .htpasswd membertwo

Thats all.

like image 66
Shayan Avatar answered Oct 28 '25 21:10

Shayan



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!