Basics of Htaccess Part – II

It's only fair to share...Share on Facebook0Share on Google+0Tweet about this on Twitter0Share on LinkedIn0Pin on Pinterest1Digg thisShare on StumbleUpon0

htaccess part 2

How to enable compression using .htaccess

In our previous article Basics of Htaccess Part – I, we have understand how to Restrict users to access pages from site using .htaccess. In this article we will learn how to enable compression using .htaccess. In the current word web technology compression is required for good speed of website. It reduces the download time and server bandwidth. Mostly all the server can compress the files before send it to download, however we can do this using .htaccess.

Enable compression using mod_deflate() in .htaccess:

The mod_deflate module provides the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network.

Enable compression using mod_gzip() in .htaccess:

We can also do by PHP file. Some time few shared hosts don’t allow the mod_deflate module. So using this method we can compress our resources.
Step 1: Create your own custom php.ini file and add mentioned lines:

 Step 2: Now we will redirect all requests for .css and .js files through gzip.php. So we have to write following code in .htaccess

 Your gzip.php file:



Leave a Reply

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


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">