views:

46

answers:

1

In my site I have some gzipped copies of the most used and largest files (because my hosting doesn't allow using the gzip compression module).

I have inserted rewrite rules in the htaccess file to send the gzipped copies when available, like this:

<FilesMatch "\.html\.gz$">
  ForceType text/html
  Header set Content-Encoding: gzip
</FilesMatch>

<FilesMatch "\.js\.gz$">
  ForceType text/javascript
  Header set Content-Encoding: gzip
</FilesMatch>

<FilesMatch "\.css\.gz$">
  ForceType text/css
  Header set Content-Encoding: gzip
</FilesMatch>

RewriteEngine on
rewritecond %{HTTP:accept-encoding} (gzip.*)
rewritecond %{REQUEST_FILENAME} !^.+\.gz$
rewritecond %{REQUEST_FILENAME}.gz -f
rewriterule ^(.+) $1.gz [L]

This works fine in FF and Chrome, but in IE8 the gzipped content is displayed like text.

A: 

You could simply activate MultiViews and let Apache do the rest:

Options +MultiViews

Then if the client accepts compression it will automatically send the appropriate file if existing (see Note on hyperlinks and naming conventions).

Gumbo
still not working..
Victor
@Victor: Are you still using your code?
Gumbo
Using -only- your code the .gz copy is not sent (neither with FF)
Victor
Note that I want the server to send the .gz copy (if available) when requesting for "file.html" even if "file.html" exists
Victor