Compressing without mod_deflate

So, what do you do when you hosting company won’t allow you to use Apache’s mod_deflate?

I wanted to use PHP’s “auto_prepend_file” and php_value directive in .htaccess to automatically prepend a file, but my server evidently doesn’t support “php_value” directives.

method I found here which ________

Here’s what I came up with.

The first step was to tell the PHP engine to compress all PHP files.

# let the server decide which level to use


Now, I had to make my static files PHP files. That was fine, but then it was returning the Content-Type as “”.

header (“Content-Type: text/css”);

header (“Content-Type: application/x-javascript”);

# Check to see if the browser accepts gzipped files
RewriteCond %{HTTP:ACCEPT-ENCODING} ^.*gzip.*$
# Now, see if that file appended with “.php” exists.
RewriteCond %{REQUEST_FILENAME}.php -f
# If so, point to that file. (Don’t allow files that start with “.”.)
RewriteRule ^([^.]+.+) /home/path/public_html/$1.php [L]

Leave a Reply

Your email address will not be published. Required fields are marked *