在.htaccess或php.ini中你如何用gzip?如何用、中你、php、htaccess

2023-09-02 00:59:16 作者:我男神叫權志龍

我在找一个简单的一行code,将使用gzip COM preSS的CSS,HTML,JS和PHP文件的Web服务器上。我怎样才能做到这一点的.htaccess文件或php.ini文件? (我的CSS和JS文件都在单独的文件夹的根目录)

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)

推荐答案

你最有可能寻找的 Apache中 mod_deflate模块模块。启用它在你的的httpd.conf ,也启用了.htaccess,然后在你的.htaccess下DOCUMENT_ROOT添加此code:

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>