h5bp/server-configs-apache

Error: envclause should be in the form env=envar

leek opened this issue ยท 4 comments

leek commented

I've been using this .htaccess configuration for awhile with great success. However, today I imported into a new project and started receiving the following:

[Thu Mar 05 14:35:31 2020] [alert] [client ::1] web/.htaccess: error: envclause should be in the form env=envar

I have copied the dist version directly without any changes. What am I doing wrong?

Thanks for opening this ticket @leek.
What is your httpd version?

leek commented

@LeoColomb Sorry for the delay, I am using Apache/2.2.34.

Sorry for the delay

No worries ๐Ÿ™‚

Apache/2.2.34

Very old version, I suggest to upgrade as soon as possible to 2.4.x.
For instance, h5bp apache config only support 2.4.10+.


I'm closing as unsupported version.

leek commented

For anyone else coming to this page encountering the same issue; this was the line that was causing the problem with Apache 2.2:

<IfModule mod_headers.c>
    Header set X-UA-Compatible "IE=edge" "expr=%{CONTENT_TYPE} =~ m#text/html#i"
</IfModule>

I changed it to this to be compatible:

<IfModule mod_headers.c>
    <IfVersion < 2.4>
        Header set X-UA-Compatible "IE=edge"

        # `mod_headers` cannot match based on the content-type, however,
        # the `X-UA-Compatible` response header should be sent only for
        # HTML documents and not for the other resources.

        <FilesMatch "\.(appcache|atom|bbaw|bmp|br|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|gz|htc|ic[os]|jpe?g|m?js|json(ld)?|m4[av]|manifest|map|markdown|md|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|wasm|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
            Header unset X-UA-Compatible
        </FilesMatch>
    </IfVersion>
    <IfVersion >= 2.4>
        Header set X-UA-Compatible "IE=edge" "expr=%{CONTENT_TYPE} =~ m#text/html#i"
    </IfVersion>
</IfModule>