A quick hack for web developers: how to use FilesMatch for a faux multiline comment.
As you may or may not now, Apache doesn’t have a native clean way to make use of multiline comments. You got to comment each line with a #
symbol (i.e hash, sharp, number, whatever). Which is tedious and take a long time in certains cases.
[Para versão em português, clique aqui]
As an example, this is one snippet of HTML 5 Boilerplate .htacces files
# Serve resources with the proper media types (f.k.a. MIME types). # # https://www.iana.org/assignments/media-types/media-types.xhtml # https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype |
Faux Multiline Comments
The good news is that you can simulate multiple lines comments in some limited situations. It won’t allow for long texts, but it allows you to temporarily disable a series of directives for when you are developing/staging, etc
You just need to use FilesMatch to encapsulate what must be commented and trying to match an improbable name (e.g. index-sbrubles123land9897BrazilQueerMuseum.php)
Something like that
<FilesMatch "index-sbrubles123land9897BrazilQueerMuseum\.(php?)$"> #commented content here </FilesMatch> |
As stated, is limited, but it can helps a lot while developing.
I would avoid to use many comments and specially this “faux multiline comment” technique in a production environment. I think the less time Apache spend parsing .htaccess files, the better (and less trouble prone).
And don’t forget that you can’t use text or any invalid apache syntax inside this false comment, anyway. It would be helpful to temporarily or conditionally disabling other directives, but not to comment text.