我需要更新APACHE(OS:Linux centos)服务器中的.htaccess文件

时间:2011-03-16 09:49:46

标签: linux apache http .htaccess compression

我正在尝试在我的APACHE 2.2(操作系统:Linux centos)中实现HTTP压缩。

因为我有以下代码需要在.htaccess中从以下URL更新。但我不知道APACHE(OS:Linux centos)服务器中的哪个.htaccess文件需要更新。 apache服务器中有很多.htaccess文件。请指导我。

在.htaccess文件中添加以下代码之前,是否需要在apache服务器中安装或激活任何模块。

http://www.askapache.com/htaccess/apache-speed-compression.html

压缩除图像以外的所有内容:

<Location />
# Insert filter
SetOutputFilter DEFLATE

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location> 

1 个答案:

答案 0 :(得分:1)

您可以将其添加到DocumentRoot中的.htaccess文件中,或者更好,将其添加到httpd.conf文件并重新启动Web服务器。