Apache deflate on files match condition
-
04-06-2021 - |
Question
I am trying to deflate files based on the FilesMatch
condition, I tried this but it doesn't deflate :
<FilesMatch \.js$>
SetOutputFilter Deflate
RewriteEngine on
RewriteRule /js/(.*.js) /pack.php?f=$1
</FilesMatch>
The rewrite rule works fine though.
Also, setting the SetOutputFilter Deflate
outside the FilesMatch
works as expected.
Solution
When apache rewrites a rule, it re-processes certain configurations (e.g <Directory>
, <DirectoryMatch>
, <Files>
, <FilesMatch>
) to match against the "re-written" URL. This appears to be your problem.
Split your rules into two <FilesMatch>
sections, one for .js$
files and another for /pack.php
. Or better, move the re-write rule outside the <FilesMatch>
section and use a single <Files pack.php>
section.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow