Browse Source

FilterProvider, support pour Apache 2.2 et 2.4

Référence :
http://www.lazaruscorporation.co.uk/blogs/arts-tech/posts/upgrading-from-apache-2-2-to-apache-2-4
lapoigne 5 years ago
parent
commit
b613882963
1 changed files with 45 additions and 40 deletions
  1. 45 40
      .htaccess

+ 45 - 40
.htaccess

@@ -124,46 +124,51 @@ AddType text/x-vcard                        vcf
   </IfModule>
 
   # HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
-#  <IfModule filter_module>
-#    FilterDeclare   COMPRESS
-# There are two way to configure the filters, according to the Apache version.
-# Apache >= 2.4
-#     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
-# Apache <= 2.2
-#     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>
+  # There are two way to configure the filters, according to the Apache version.
+  <IfModule version.c>
+    <IfModule filter_module>
+      FilterDeclare   COMPRESS
+      <IfVersion >= 2.4>
+        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'"
+      </IfVersion>
+      <IfVersion <= 2.2>
+        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
+      </IfVersion>
+      FilterChain     COMPRESS
+      FilterProtocol  COMPRESS  DEFLATE change=yes;byteranges=no
+    </IfModule>
+  </IfModule>
+
 
   <IfModule !mod_filter.c>
     # Legacy versions of Apache