Add a comment on .htpasswd
Asked Answered
L

2

20

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 :

  • Not possible
  • Possible with ::
  • Possible with # (like .htaccess)

::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 #)

Landel answered 4/9, 2015 at 10:32 Comment(0)
I
31

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

Ingeingeberg answered 4/9, 2015 at 10:48 Comment(0)
N
3

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.

Nought answered 4/9, 2015 at 10:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.