Disabling compression for IE pre SP2 with Apache m

2019-07-31 08:07发布

I am trying to replicate this fix ( http://sebduggan.com/posts/ie6-gzip-bug-solved-using-isapi-rewrite ) with Apache mod_rewrite, but with no success... Can somebody help me translate those ISAPI rules to APACHE mod_rewrite? I don't know how to 'translate' those rules...

My objective is to avoid sending compressed css and js when the user has an XP version prior to SP2, since there is a bug that prevents IE6&7 under SP1 to read the gzipped CSSs of my website BuscoUnViaje.com

The rules I am trying to 'translate' to Apache mod_rewrite:

RewriteCond %{HTTP:User-Agent} MSIE\ [56]
RewriteCond %{HTTP:User-Agent} !SV1
RewriteCond %{REQUEST_URI} \.(css|js)$
RewriteHeader Accept-Encoding: .* $1

Thanks in advance...

1条回答
淡お忘
2楼-- · 2019-07-31 08:48

mod_rewrite has no RewriteHeader directive, so I used it in conjunction with mod_headers to achieve the desired result:

RewriteEngine on

<IfModule mod_headers.c>
  RewriteCond %{HTTP_USER_AGENT} MSIE\ [56]
  RewriteCond %{HTTP_USER_AGENT} !SV1
  RewriteCond %{REQUEST_URI} \.(css|js)$
  RewriteRule .* - [E=REMOVE_IE_ACCEPT_ENCODING:1]

  <LocationMatch \.(css|js)$>
    RequestHeader set Accept-Encoding "" env=REMOVE_IE_ACCEPT_ENCODING
  </LocationMatch>
</IfModule>

Hope it helps!

查看更多
登录 后发表回答