Do Apache config files support block commenting?
Solution 1:
I came across this post from a Google search for "Apache block comment". Later, I discovered a non-perl, non-import solution from Apache's core documentation (although I'm sure this is very non-intended practice). From the core documentation for Apache 2.0 http://httpd.apache.org/docs/2.0/mod/core.html, you can see that the tag <IfDefine>
will handily ignore statements when the parameter you specify does not exist:
<IfDefine IgnoreBlockComment>
...
</IfDefine>
So that'll successfully "comment" out the statements in between.
Solution 2:
I am not sure if apache has such type of comments.
As a workaround, you can use include statement in the following way:
yourfile.conf:
<Directory>
....
</Directory>
When you want to comment this block, you just need to comment out the include line:
#include yourfile.conf
Solution 3:
AFAIK, Apache doesn't support this.
But, if you're using vim
, here's a tip (from my co-worker) to comment out a Apache config block.
For instance, given this snippet:
<Directory "a/b/c">
SetEnvIf X-Forwarded-For ^x\.y\.z\.t let_me_in
Order allow,deny
allow from env=let_me_in
ErrorDocument 403 http://google.com
</Directory>
Put the cursor under the D
character at the opening <Directory ...>
line and type the following:
V/Dir
-> Enter
followed by:
:s/^/#/
-> Enter
V
- to highlight the current line/Dir
- selects the whole block:s/^/#/
- puts a#
at the begin of each line