I have a few sites on a shared host that is running Apache 2. I would like to compress the HTML, CSS and Javascript that is delivered to the browser. The host has disabled mod_d
You can try your luck with mod_rewrite.
Create a script that takes a local static file name as input, through e.g. $_SERVER['QUERY_STRING']
and outputs it in compressed form. Many providers don't allow configuring mod_rewrite
with .htaccess
files or have it completely disabled though.
If you haven't used rewrite before, I recommend a good beginner's guide, like probably this one. This way you can make the apache redirect all requests for a static file to a php script. style.css will be redirected to compress.php?style.css for instance.
As always be extremely cautious on the input you accept or you have an XSS
exploit on your hands!