Page 1 of 1

Use of comments in Apache configuration files

Posted: Fri 25 Oct 2013 11:16
by David Gibson
Hi Cookie (and anyone else reading this),
Ive been having some really strange problems with a .htaccess file, causing 500 Internal Server Error messages and so I started writing this posting to ask you what was going on. Then I thought I should probably check the error log first, and then RTFM. I discovered something I never knew, which is that in Apache configuration files, the comment character # cannot appear "anywhere" in the line. says ...
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.
Youre going to tell me that's obvious. But Ive been using "comments after directives" for years (and with random strange problems, I have to admit). In the current case, my comment included the date of the modification, e.g. # altered on 25 Oct 2013, and I discovered by trial and error that the "2013" was causing the server to crash. I now realise that this was because it was trying to parse it as an IP address and crashing with the logged message "The specified IP address is invalid". Im clearly not the only one to fall into this trap because I based certain aspects of the structure of my .htaccess files on those of "another web designer within BCA" :-). So, Im wondering...
  1. If a comment after a directive does not cause a problem, is it OK to leave it in (performance issues aside), and
  2. Is there a comment delimiter that is valid after a directive?