Take the 2-minute tour ×

I have two files: index.html and index.html.gz.

If the client supports gzip, i want to serve index.html.gz. If the client does not, i want to serve index.html.

This should work if the visitor visits www.site.com

Really not sure how this can be done :(

EDIT: I'm trying to get it to work in .htaccess

I can do it easily with other pages by doing:

RewriteCond %{HTTP:Accept-encoding} gzip
RewriteRule ^contact\.html$ contact.gz

But i can't do it with the index since people don't type in www.site.com/index.html. They leave index.html out.

share|improve this question
It's not clear what you're asking... Wild guess: Gzip compression is supported by webservers (including apache), so you just need to turn it on and the client browser will take care of the rest (no need for index.html.gz!) - most browsers have supported gzip for years now. –  nickhar Nov 7 '12 at 22:22
I understand. But I'm compressing all my files manually since i don't want to waste cpu cycles to do it. My pages are static and never change, i dont need the server to recompress them each time a new visitor arrives. That increases Time-To-First-Byte and thus decreases load speed. –  user1807574 Nov 7 '12 at 22:25
OK... Thats an interesting, if somewhat retro approach. I'd suggest putting .htaccess filetype redirects in your question title. –  nickhar Nov 7 '12 at 22:36
add comment


Your Answer



Browse other questions tagged or ask your own question.