我使用.htpasswd
密码保护某个目录我的服务器上。 然而,我注意到,每次我这样做sudo htpasswd -c /etc/apache2/.htpasswd newuser
我的当前内容.htpasswd
将被覆盖。 我的网站的每个目录上htpasswd的自己的用户。
我怎么能不覆盖,而不是添加新用户对我的.htpasswd
?
我使用.htpasswd
密码保护某个目录我的服务器上。 然而,我注意到,每次我这样做sudo htpasswd -c /etc/apache2/.htpasswd newuser
我的当前内容.htpasswd
将被覆盖。 我的网站的每个目录上htpasswd的自己的用户。
我怎么能不覆盖,而不是添加新用户对我的.htpasswd
?
Exact same thing, just omit the -c
option. Apache's docs on it here.
htpasswd /etc/apache2/.htpasswd newuser
Also, htpasswd
typically isn't run as root. It's typically owned by either the web server, or the owner of the files being served. If you're using root to edit it instead of logging in as one of those users, that's acceptable (I suppose), but you'll want to be careful to make sure you don't accidentally create a file as root (and thus have root own it and no one else be able to edit it).
FWIW, htpasswd -n username
都将输出结果直接输出到标准输出,并完全避免接触文件。