-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.htaccess Error 500 in Apache 2.4 because of FilterProvider #1012
Comments
So, this:
Would become something like this:
Easy enough to change, but how do we detect which syntax should be used? |
Thanks for your reaction. I'm no expert. In fact I signed up at github just to post this to help myself and others. I think it should be noted in the Boilerplate Docs. Also, maybe a easy-to-see note at the Boilerplate front page to somewhere where people can copy the new syntax to their own .htaccess. I guess it's a bad idea to provide the new syntax commented out in .htaccess right? |
Just posting here to keep track of this.. I'm partly to blame for this to land in the h5bp to begin with. Over a year and it's still keeping coming back up.. sheeshh... I'm going to dig into this and see what can be done about this. |
Is it enough if we add a comment in the |
I'm using 2.4 too, so what is the final correct syntax? |
Ok, so if I'm using 2.4, what is the final and correct syntax? |
Looks like you have to use this, as @mathiasbynens already pointed out:
|
You can use
|
I think the |
This didn't work for me. It didn't compress some files. The actually returned content type is not just 'text/html'. It's 'text/html; charset=utf-8'. Using "%{CONTENT_TYPE} = 'text/html'", i think it means that the content type must match 'text/html', which it doesn't. Changing it to an expression did the trick. The solution that works for me:
I tried to combine some lines: "%{CONTENT_TYPE} =~ m|^text/(html|css)|", but that gave errors. |
Maybe a fallback for those that don't have version module enabled. This should default to 2.2 in the absence of the version module. I used @gpeltink's code above for 2.4 and above. This is all untested.
|
I've got a more compact code for apache 2.4:
|
I think this should be wrapped in |
It already is. |
Thanks for the work you guys have put into this so far. Where are we at with a potential solution? |
I believe the solution I posted (which really just merged @marisk's and @gpeltink's solutions) is probably the way to go if you don't mind its verbosity. The only issue with it would be if someone has Apache 2.4 and does not have the version module enabled. The version module is used to tell the difference between Apache 2.4 and "less than 2.4." The code simply assumes "less than 2.4" in the absence of the version module since 2.4 isn't common just yet. # HTML, TXT, CSS, JavaScript, JSON, XML, HTC: <IfModule filter_module.c> <IfModule version.c> <IfVersion >= 2.4> FilterDeclare COMPRESS FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} =~ m#^text/(html|css|plain|xml|x-component)#i" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} =~ m#^application/(javascript|json|xml|xhtml+xml|rss+xml|atom+xml|vnd.ms-fontobject|x-font-ttf)#i" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} =~ m#^image/(svg+xml|x-icon)#i" FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'font/opentype'" FilterChain COMPRESS FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no </IfVersion> <IfVersion < 2.4> FilterDeclare COMPRESS FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $image/x-icon FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype FilterChain COMPRESS FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no </IfVersion> </IfModule> <IfModule !version.c> FilterDeclare COMPRESS FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $image/x-icon FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype FilterChain COMPRESS FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no </IfModule> </IfModule> I have not submitted a pull request because I don't feel like it's my work (again, I only merged the work of two other guys) and because I haven't tested it. |
The last code posted works great for me. |
cc @h5bp/server-configs |
We need more peer review on this change. It doesn't feel like it has been tested enough, and it seems a bit odd that you have to duplicate a whole chunk of code. |
I did a little bit of "digging" yesterday and it seems the legacy portion of the hypertext access file (with some additions) can be also used for Apache 2.2 - 2.4. 1) Information about
|
Nice work @alrra! Do you want to make a pull request? Thanks |
huge! nice digging @alrra ! |
Works with Apache ≥ 2.1 and requires `mod_deflate` and `mod_filter` to be enabled. However, use of Apache < 2.2 is no longer recommended. For Apache ≥ 2.1 → 2.3.7, `mod_filter` isn't needed, but requiring it and using this solution is the best way going forward (plus, it doesn't introduce other dependencies to other modules like, for example, `mod_version`). Fix h5bp/html5-boilerplate#1012 Ref h5bp/html5-boilerplate#1173
Works with Apache ≥ 2.1 and requires `mod_deflate` and `mod_filter` to be enabled. However, use of Apache < 2.2 is no longer recommended. For Apache ≥ 2.1 → 2.3.7, `mod_filter` isn't needed, but requiring it and using this solution is the best way going forward (plus, it doesn't introduce other dependencies to other modules like, for example, `mod_version`). Fix h5bp/html5-boilerplate#1012 Ref h5bp/html5-boilerplate#1173
This method is not working for me for Apache 2.4/wordpress installation. Html is not compressing. Other file like js and css is compressed. Any suggestions? |
From http://httpd.apache.org/docs/2.4/upgrading.html:
From http://httpd.apache.org/docs/2.4/mod/mod_filter.html:
The text was updated successfully, but these errors were encountered: