0

From the Apache 2 docs:

The effect of MultiViews is as follows: if the server receives a request for /some/dir/foo, if /some/dir has MultiViews enabled, and /some/dir/foo does not exist, then the server reads the directory looking for files named foo.*, and effectively fakes up a type map which names all those files...

Is there any way to make MultiViews do its magic even if the requested file does exist? For example I might have these files:

  • foo.html
  • foo.html.gz

When /foo.html is requested, I want to return foo.html.gz if the Accept-Encoding: gzip header is sent.

MultiViews can do this fine, but you have to either request just /foo or rename foo.html to foo.html.en (which is hackish, and doesn't work if you request from a non-English browser).

Adam Ernst
  • 177
  • 1
  • 6

1 Answers1

0

This will make it load the .gz file if gzip compression is accepted. Otherwise it'll skip this rule and just load the normal html file.

Note: You must have the mod_rewrite module installed to use this.

RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule ^(.*).html$ $1.html.gz [NC,L,QSA]
Sarah Ryan
  • 251
  • 1
  • 3
  • 11