Using php.ini, .htaccess and zlib.output to compre

2019-07-03 00:06发布

问题:

Ive been attempting to compress my website with gzip - although my server doesnt allow me do use mod_deflate, so ive found an alternative solution here: http://www.warpconduit.net/2010/10/23/enabling-gzip-compression-of-php-css-and-js-files-without-mod_deflate/

It works wonders on the .php files in my root directory, I am wondering how I can integrate this into my js folders

php.ini

output_handler = Off
zlib.output_compression = On
zlib.output_handler = ob_gzhandler

.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*\.js) gzip.php?type=js&file=$1
RewriteRule ^(.*\.css) gzip.php?type=css&file=$1
</IfModule>

The gzip.php file is located on link above...

Will I have to add additional RewriteRule's for each folder that contains the .js files I would like to compress? For example:

Add, RewriteRule ^(system\js.js) gzip.php?type=js&file=$1

Thanks for any help you can provide, Ive been trying to work this out the past couple of days finally feel like I am getting somewhere.

标签: php gzip