Apache mod_mem_cache vary-deflate buq FIx但需要重写规则建议

时间:2010-11-27 17:42:09

标签: apache caching mod-rewrite url-rewriting

IF查询字符串?g并键入css或js - 禁用gzip-deflate

RewriteCond %{REQUEST_URI} \.(css|js)$

RewriteCond %{REQUEST_METHOD} GET

RewriteCond %{QUERY_STRING} ^g$

RewriteRule ^(.*)$ $1 [QSA,E=no-gzip:1,PT,L]

如果用户代理redirecto没有gzip支持文件查询字符串?g eq。的style.css?克

RewriteCond %{REQUEST_URI} .(css|js)$

RewriteCond %{REQUEST_METHOD} GET

RewriteCond %{HTTP:Accept-Encoding} !^gzip\,deflate$

RewriteCond %{QUERY_STRING} !^g$

RewriteRule "^([a-zA-Z0-9_-]*)\.(css|js)$" $1.$2?g [R=301]

我的问题是301需要rel路径但是转到默认目录

http:// localhost/style/style.js -> http://d:\some\path/style.js?g

http:// localhost/js/e.js -> http://d:\some\path/e.js?g

要解决这个问题,我认为需要了解真实路径eq

RewriteRule "^([a-zA-Z0-9_-]*)\.(css|js)$" http://%{HOST}/%{PATH}/$1.$2?g [R=301]

但我不知道如何命名这个

1 个答案:

答案 0 :(得分:0)

RewriteRule "^([a-zA-Z0-9_-]*)\.(css|js)$" http://%{HTTP_HOST}%{REQUEST_URI}?g [R=301]