Disabling compression for IE pre SP2 with Apache mod_rewrite

拈花ヽ惹草 提交于 2019-12-13 00:45:31

问题


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:


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!



来源:https://stackoverflow.com/questions/2733573/disabling-compression-for-ie-pre-sp2-with-apache-mod-rewrite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!