We help IT Professionals succeed at work.

.htaccess and GZip/ZLib

Last Modified: 2012-05-08
Hey guys,

I am trying to enable output compression through the main .htaccess file in my root directory and am using this code :
<ifModule mod_php4.c>
    php_flag zlib.output_compression on
    php_value zlib.output_compression_level 1

The webserver is running Apache version 2.2.11 (Unix) and PHP version 5.2.9  however I have tested this to see if compression is working on http://www.gidnetwork.com/tools/gzip-test.php and it comes back that compression is not enabled. Also, it comes back that my index.php size is 677 bytes when it really isnt its 4kb on the server? Any ideas?
Watch Question


Ok ignore the filesize bit - its because it was passworded but i just took it off and now its 30kb!!!! Everything else stil lapplies though - could someone tell me how to enable this compression? :) thanks

If you're running PHP5 why are you enabling an Apache module that looks like PHP4 (mod_php4). Also, I'm unclear as to whether you are trying to install zlib for PHP or zlib for Apache. If you want Apache to compress the web pages then you should be using mod_deflate

Top Expert 2008

> <ifModule mod_php4.c>
> and PHP version 5.2.9

I wouldn't expect that mod_php for php5 identifies itself as mod_php4. Remove the <ifModule mod_php4.c>  ... </ifModule>  containers.


Ah ha! I did know that I should change "mod_php4.c" but I didn't know what I should change it to. Also, when i remove those tags i get a 500 internal server error and the site doesnt work.

I want the webpages to be compressed. I always thought i should do this with the Zlib.output_compression? What is the deflate mod? My intial query was me wanting to install Zlib for PHP unless you guru's can reccommend something else? :)
Top Expert 2008
This one is on us!
(Get your first solution completely free - no credit card required)

To compress the webpages I would install mod_deflate via your repository tool (YUM, Zypper, YasT apt-get etc...)

Also this may be useful http://www.howtoforge.com/apache2_mod_deflate


I'm running under phpsuexec so i needed to change the settings in the php.ini file - as found out from the ever helpful support team! :)

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.