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
精彩评论