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

How can I get Apache 2.2 on Centos to serve static .html.gz files from local disk to browsers, without them being prompted to download the file (ie - I want it rendered normally in the browser)?

share|improve this question
1  
Why do you need to do that? You can gunzip them and serve them compressed using apache module mod_deflate. –  Khaled May 9 '12 at 12:04
1  
See stackoverflow.com/questions/75482/… –  symcbean May 9 '12 at 13:22
    
I'd like to save local disk space by precompressing and the other question doesn't go into detail - a config snippet would be nice –  jamespo May 9 '12 at 18:48

2 Answers 2

Try this:

LoadModule deflate_module modules/mod_deflate.so
<Directory /path/to/gzipped/files>
   SetOutputFilter INFLATE
</Directory>
share|improve this answer
    
unfortunately I still get prompted to download the .gz –  jamespo May 16 '12 at 9:50

Use the following:

# Location block does not work for MultiviewsMatch
<Directory /var/www/html>
  AddEncoding x-gzip .gz
  Options +MultiViews
  MultiviewsMatch Filters
</Directory>

Make sure mod_negotiation, mod_deflate, and mod_mime are loaded elsewhere in the config. They should be standard. On my CentOS install, it appears the AddEncoding line is present but commented out. Just uncommenting that line may be sufficient.

It's a good idea to limit the scope of this setting - as it may result in .gz files being served as content-encoded everywhere, even when you want to send them as a download.

share|improve this answer
    
unfortunately I still get prompted to download the .gz –  jamespo May 16 '12 at 9:50
    
Comment out 'AddType application/x-gzip .gz .tgz' in httpd.conf, and it will no longer download those files. They are now an encoding, not a type. You can AddType and AddEncoding on a Directory or Location basis to toggle this behavior. –  jmanning2k Jun 15 '12 at 15:19

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.