1

I guess you all know the LoadModule directive form mod_so. I want to do the opposite, unload module for specific directory via .htaccess file. Does UnloadModule exist?

I want to reach highest script compatibility by *disabling all modules except mod_rewrite*, because unwanted modules are messing with my script in some way. Is there an easy way?

Side question: How to disable mod_deflate only? It is the biggest badass. I want to handle compression internally in my scripts.

4

2 回答 2

2

1.我认为无法卸载已经加载的模块。这就是我在#1上所能说的。

2.让我们把这段代码放在.htaccess中:

<IfModule deflate_module>
    # Insert filter
    SetOutputFilter DEFLATE
    # Don't compress images
    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

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

这将压缩 .html 文件(当然,只要它足够大)。

现在,让我们添加html到排除扩展名列表中:

    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|html)$ no-gzip dont-vary

现在在浏览器中重新加载相同的 html 文件(确保浏览器实际加载它是新鲜的(应该是 200 响应),而不是从缓存或通过 304 Not Modified 响应)。它现在发送完全没有压缩的 html 文件。Firebug 确认:压缩后只有 480 字节,未压缩数据只有 11.6 KB(html 文件基本上是一段重复 20 次左右的文本,因此压缩效果非常好)。

我相信你可以很容易地根据你的需要修改它(在我的服务器上,压缩没有全局启用——这是我在需要时使用的代码——所以很遗憾,我无法为你提供 100% 准确的代码)。例如:

SetEnvIfNoCase Request_URI .+$ no-gzip dont-vary
于 2011-09-01T20:30:28.283 回答
0

您可以通过在配置中根本没有针对相关模块的 LoadModule 指令来防止模块被加载。

于 2011-09-01T20:04:08.443 回答