I don't have the htaccess, but since I did that on Nginx some time ago, I can at least give you the bash script.
I scans a directory (and its subdirectories) and gzip the listed filetypes. It also regenerates gzip when the source is more recent.
#! /bin/bash
# jve - 2011
# this script checks a list of directories for a list of extensions and
# generated gzipped versions of the files that are found
# if the modification date of a file is newer than its gzipped version
# then the gzip file is regenerated
# specify a filetype like *.css or a filename like index.html
# leave one space between each entry
FILETYPES="*.css *.jpg *.jpeg *.gif *.png *.js *.html"
# specify a list of directories to check recursively
DIRECTORIES="/var/www/nginx_default/*"
for currentdir in $DIRECTORIES
do
for extension in $FILETYPES
do
find $currentdir -iname $extension -exec bash -c 'PLAINFILE={};GZIPPEDFILE={}.gz; \
if [ -e $GZIPPEDFILE ]; \
then if [ `stat --printf=%Y $PLAINFILE` -gt `stat --printf=%Y $GZIPPEDFILE` ]; \
then echo "$GZIPPEDFILE outdated, regenerating"; \
gzip -9 -f -c $PLAINFILE > $GZIPPEDFILE; \
fi; \
else echo "$GZIPPEDFILE is missing, creating it"; \
gzip -9 -c $PLAINFILE > $GZIPPEDFILE; \
fi' \;
done
done
the link to the original article is here: http://wiki.linuxwall.info/doku.php/en:ressources:dossiers:nginx:nginx_performance_tuning