Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

.htaccess and Apache 2.4 #8683

Closed
leofeyer opened this issue Mar 27, 2017 · 6 comments
Closed

.htaccess and Apache 2.4 #8683

leofeyer opened this issue Mar 27, 2017 · 6 comments
Labels

Comments

@leofeyer
Copy link
Member

It seems that our .htaccess file is no longer compatible with Apache 2.4. This is a common problem, which is e.g. discussed here: h5bp/html5-boilerplate#1012

The following change fixes the syntax for Apache 2.4 but is not compatible with Apache 2.2:

##
# Gzip compression
# @see https://github.com/h5bp/html5-boilerplate
##
<IfModule mod_deflate.c>
  # Current Apache versions (>= 2.2)
  <IfModule filter_module>
    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
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/html'"
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/css'"
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/plain'"
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/xml'"
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/x-component'"
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/javascript'"
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/json'"
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/xml'"
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/xhtml+xml'"
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/rss+xml'"
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/atom+xml'"
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/vnd.ms-fontobject'"
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'image/svg+xml'"
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'image/x-icon'"
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/x-font-ttf'"
+    FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'font/opentype'"
    FilterChain     COMPRESS
    FilterProtocol  COMPRESS  DEFLATE change=yes;byteranges=no
  </IfModule>
  # Legacy Apache versions
  <IfModule !mod_filter.c>                                                                                        
    AddOutputFilterByType DEFLATE text/html text/plain text/css application/json                                                                        
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE text/xml application/xml text/x-component                                                                                         AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
    AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
  </IfModule>
</IfModule>

@contao/developers How do we fix this?

@Toflar
Copy link
Member

Toflar commented Mar 27, 2017

Server configuration...not our problem. I think we should deliver a default for the latest version and that's it. People using an older version should update and if they insist on keeping an older version then they need to figure out themselves. We could add it to the docs.

@leofeyer
Copy link
Member Author

Fine with me. But we should generally comment out any code from which we know that it is only compatible with a specific Apache version.

@Toflar
Copy link
Member

Toflar commented Mar 27, 2017

What about the IfVersion module?

@leofeyer
Copy link
Member Author

Doesn't the IfVersion module require mod_version?

@Toflar
Copy link
Member

Toflar commented Mar 27, 2017

Yes, so our default could deliver all statements within the <IfModule mod_version.c><IfVersion> statement. Then it's always compatible, works automatically in best case (you have mod_version) and if not, you have the code needed for your version right at hand.

@leofeyer leofeyer added this to the 3.5.26 milestone Mar 29, 2017
@leofeyer
Copy link
Member Author

leofeyer commented Mar 30, 2017

Sorry, I just realize that we are not using the FilterProvider directive anymore (see #4552). My diff is based on an old version of the .htacces file, so never mind.

@leofeyer leofeyer added invalid and removed defect labels Mar 30, 2017
@leofeyer leofeyer removed this from the 3.5.26 milestone Mar 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants