Particular RewriteCond breaks Apache config parser


Attempting to run letsencrypt, it bombs out, failing to parse my Apache config:

Traceback (most recent call last):
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt/plugins/", line 103, in prepare
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt_apache/", line 150, in prepare
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt_apache/", line 68, in check_parsing_errors
    raise errors.PluginError(msg)
PluginError: ('There has been an error in parsing the file (%s): %s', u'/etc/apache2/sites-enabled/', u'Syntax error')

Apache thinks my config is valid:

# apachectl configtest
Syntax OK

It turns out the problematic line is this one:

RewriteCond %{HTTP_HOST} !=""

As far as I can tell, this is valid syntax if I’m not misreading the Apache 2.4 mod_rewrite documentation.


Let’s Encrypt uses Augeas for the configuration file parsing. Perhaps you could have a look at the httpd.aug (original here) file why it doesn’t parse that particular directive? I myself don’t have any clue about Augeas lenses or what they are all about :stuck_out_tongue: