.htpasswd without .htaccess

I would like to protect the web folder through .htpasswd. However, since the .htaccess file is under version control, I would prefer not to interfere with it.

Instead, I would like to have a configuration in
/ Etc / apache2 / sites with support / MySite
/ etc / apache 2 / .htpasswd

Any idea what I need to insert into the apache configuration file "mysite"?

So far so

<VirtualHost (ip address):80> ServerName my.domain DocumentRoot /var/sites/sitename ServerAdmin ... </VirtualHost> 
+4
source share
1 answer

Hureka, I realized this myself .. or what I think is to be a solution.

 <VirtualHost (ip address):80> ServerName my.domain DocumentRoot /var/sites/sitename/ ServerAdmin ... <Directory /var/sites/sitename/> AuthUserFile /etc/apache2/.htpasswd AuthGroupFile /dev/null AuthName "What is the pw" AuthType Basic require user (username) </Directory> </VirtualHost> 

.htpasswd can be created in the usual way via the command line,

 # htpasswd /etc/apache2/.htpasswd (username) 

EDIT: anthony in the comment below strongly recommends using https / SSL so that the password is not sent unencrypted.

+5
source

All Articles