YUI压缩机&x2B;gzip在jQuery中导致非法字符错误

YUI压缩机&x2B;gzip在jQuery中导致非法字符错误,jquery,mod-rewrite,gzip,rewrite,yui-compressor,Jquery,Mod Rewrite,Gzip,Rewrite,Yui Compressor,当我使用YUI压缩器缩小jquery时,它工作得很好。 然后,当我添加gzip压缩(并通过mod rewrite提供此版本)时,gzip版本抛出以下错误: 第1行jquery.min.js中的非法字符 第1行是: �������M�����������s�8.�0�?�!深圳�dKr�=� 这将导致“jquery未定义”错误。 我使用以下重写规则来提供gzip版本: #Check to see if browser can accept gzip files. ReWriteCond %{HTT

当我使用YUI压缩器缩小jquery时,它工作得很好。 然后,当我添加gzip压缩(并通过mod rewrite提供此版本)时,gzip版本抛出以下错误:

第1行jquery.min.js中的非法字符

第1行是:

�������M�����������s�8.�0�?�!深圳�dKr�=�

这将导致“jquery未定义”错误。 我使用以下重写规则来提供gzip版本:

#Check to see if browser can accept gzip files.
ReWriteCond %{HTTP:accept-encoding} (gzip.*)
#make sure there's no trailing .gz on the url
ReWriteCond %{REQUEST_FILENAME} !^.+\.gz$
#check to see if a .gz version of the file exists.
RewriteCond %{REQUEST_FILENAME}.gz -f
#All conditions met so add .gz to URL filename (invisibly)
RewriteRule ^(.+) $1.gz [L] 
我找不到任何其他人发生过这种事。 想法


附言——2008年jQuery论坛上似乎也提出了同样的问题。它有278个视图,但没有答案:

如果让我猜的话,我会说Apache已经在压缩您的JS文件,而您的重写导致请求被双重压缩


删除重写规则并查看Firebug中的jQuery文件。您将在那里看到它是否已被压缩。

结果证明您是对的!但这是Firebug的YSlow插件告诉我的,而不是Firebug本身。谢谢