4wk_
4wk_

Reputation: 2743

Add a comment on .htpasswd

I was wondering if it is possible to write a comment on the .htpasswd file.

Why ? Because sometimes, we have to "disable" some users, just for a couple of days. I checked on StackOverflow and other websites, and it seems pretty confusing :

::bar:$apr1$G3iw8iqc$IGNoXDw7e7HolcSgE/V0a0

#foo:$apr1$3dJLDmbn$/zODUbSXmqDfeeCmMFKO8/

NB: I don't want to disable users by adding a fake char at the beginning of the line, for instance. I want a clean way, if this is possible ;)

After testing, both seems to work, but I want some expert opinions (and btw VIm doesn't syntax highlight neither :: nor #)

Upvotes: 21

Views: 10278

Answers (2)

Sawrub
Sawrub

Reputation: 693

Apache's config file format (of which .htaccess files are one example) doesn't technically support inline comments, only full-line comments (i.e. a line beginning with a #).

Lines that begin with the hash character "#" are considered comments, and are ignored. Comments may not be included on a line after a configuration directive. -- Official Apache 2.4 manual

Upvotes: 31

Abel
Abel

Reputation: 57169

As far as I know, the syntax of these files is the same as other Apache configuration files. Apache does not document this specifically for .htpasswd, but says generically that comments can be added to their config files by using #. Comments can only span one line. Directives must be on one line, but can span multiple lines when appended with \ at the end of the line.

Upvotes: 3

Related Questions