简体   繁体   English

htaccess mod_deflate在共享服务器上不起作用

[英]htaccess mod_deflate does not work on shared server

I'm developing a website in PHP and I have large JS files that I want to compress. 我正在用PHP开发网站,但我有大的JS文件要压缩。 So, I added this in my .htaccess file: 因此,我在.htaccess文件中添加了此代码:

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

It works great on my local wamp server install but once I move the files on my shared server, the DEFLATE command does not work. 它在我的本地wamp服务器安装上很好用,但是一旦我在共享服务器上移动了文件,DEFLATE命令就不起作用。 I don't know why... mod_deflate is enabled on the webserver, aswell as bz2, gzip. 我不知道为什么...在网络服务器上启用了mod_deflate以及bz2,gzip。 I am allowed to user htaccess, I've cheched...Plus that I have other rules and commands running in htaccess. 我被允许使用htaccess用户,我已经检查过...此外,我还有其他在htaccess中运行的规则和命令。 So the DEFLATE is the only one that does not work... Does anyone know why it works on my localhost and not on my webserver too ? 因此,DEFLATE是唯一不起作用的...没有人知道为什么它可以在我的本地主机而不是我的Web服务器上工作吗? Is there any module/extension that I need to enable on my webserver that I don't know of ? 是否需要在我不知道的Web服务器上启用任何模块/扩展名?

Any ideas ? 有任何想法吗 ?

Thank you! 谢谢!

Are you sure mod_deflate is loaded and available? 您确定mod_deflate已加载并且可用吗? Apache doesn't throw an error if you set it as filter although it is not loaded. 如果未将Apache设置为过滤器,则不会引发错误。

You can use the apache_get_modules function to see what modules are loaded. 您可以使用apache_get_modules函数查看加载了哪些模块。

Hmm, I guess you're right..I've checked my loaded modules with apache_get_modules() and mod_deflate wasn't there. 嗯,我想你是对的。我已经用apache_get_modules()检查了已加载的模块,而mod_deflate不存在。 I also checked on my localhost and mod_deflate was there. 我还检查了我的本地主机,并在那里找到了mod_deflate。 I've sent a ticket to support. 我已经发送了一张票来支持。 I hope I'll get this done. 我希望我能做到。

Thank you for your help. 谢谢您的帮助。

似乎许多共享主机计划已禁用mod_deflate,因为它占用过多的CPU……至少在它们装入您的服务器上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM