Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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).

share|improve this question

1 Answer 1

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]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.