开发者

htaccess rule not working with filesmatch

<FilesMatc开发者_如何学Goh ".js">
RewriteCond %{HTTP_USER_AGENT} !".*Safari.*"
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^resources/widget/(.*).js$ /resources/widget/$1.js.gz [L]
ForceType text/javascript
Header set Content-Encoding: gzip
</FilesMatch>

This doesnt work with a js file

RewriteCond %{HTTP_USER_AGENT} !".*Safari.*"
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^resources/widget/(.*).js$ /resources/widget/$1.js.gz [L]
ForceType text/javascript
Header set Content-Encoding: gzip

This works with a js file but then it corrupts the rest of the page.

How can I just apply this rule to a js file


RewriteCond %{HTTP_USER_AGENT} !".*Safari.*"
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*).js$ $1.js.gz [L]
ForceType text/javascript
Header set Content-Encoding: gzip

create a htaccess in the js directory and just use this.


<FilesMatch "\.js$">
RewriteCond %{HTTP_USER_AGENT} !".*Safari.*"
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*).js$ $1.js.gz [L]
ForceType text/javascript
Header set Content-Encoding: gzip
</FilesMatch>0
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜