Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 :

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

like image 215
4wk_ Avatar asked Sep 04 '15 10:09

4wk_


People also ask

How do I comment in htaccess file?

htaccess file is done by adding a # at the beginning of the line(s) that you would like to comment. The # is required before each line of comment. Essential this instructs the server to ignore that line in the . htaccess file.

Where is my .htpasswd path?

php echo dirname(__FILE__) . '/. htpasswd'; ?> Then access it via your browser and it should display the full path you'll need to put in your .


1 Answers

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

like image 79
Sawrub Avatar answered Oct 16 '22 07:10

Sawrub