function css_gzip_create_htaccess in CSS Gzip 6
Generate & write the .htaccess file inside the files/css dir.
Parameters
$htaccess: Path and filename of the subdir .htaccess file.
1 call to css_gzip_create_htaccess()
- css_gzip_preprocess_page in ./
css_gzip.module - Implementation of template_preprocess_page().
File
- ./
css_gzip.module, line 150 - Gzips aggregated CSS files if CSS Optimization is turned on.
Code
function css_gzip_create_htaccess($htaccess) {
$htaccess_contents = <<<EOT
# Requires mod_mime to be enabled.
<IfModule mod_mime.c>
# Send any files ending in .gz with x-gzip encoding in the header.
AddEncoding gzip .gz
</IfModule>
# Gzip compressed css files are of the type 'text/css'.
<FilesMatch "\\.css\\.gz\$">
ForceType text/css
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine on
# Serve gzip compressed css files
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\\.gz -s
RewriteRule ^(.*)\\.css \$1\\.css\\.gz [L,QSA,T=text/css]
</IfModule>
EOT;
file_save_data($htaccess_contents, $htaccess, FILE_EXISTS_REPLACE);
variable_set('css_gzip_htaccess_size', filesize($htaccess));
}