Daniel Harris
Daniel Harris

Reputation: 1905

How do you use gzip in .htaccess or php.ini?

I'm looking for a simple one line code that will use gzip to compress css, html, js, and php files on the web server. How can I do this with the .htaccess file or php.ini file? (My css and js files are in seperate folders in the root directory)

Upvotes: 2

Views: 2900

Answers (2)

Sauryabhatt
Sauryabhatt

Reputation: 269

<Files *>
    #Compress
    SetOutputFilter GZIP
</Files>

Upvotes: 2

anubhava
anubhava

Reputation: 784968

You're most likely looking for mod_deflate module in Apache. Enable it in your httpd.conf and also enable .htaccess then add this code in your .htaccess under DOCUMENT_ROOT:

<FilesMatch "\\.(js|css|html|htm|php)$">
SetOutputFilter DEFLATE
</FilesMatch>

Upvotes: 0

Related Questions