与 LoadModule Apache (.htaccess) 指令相反
我想你们都知道 mod_so 形式的 LoadModule 指令。我想做相反,通过 .htaccess 文件卸载特定目录的模块。 UnloadModule 是否存在?
我想通过*禁用除 mod_rewrite 之外的所有模块来达到最高的脚本兼容性,因为不需要的模块会以某种方式扰乱我的脚本。有没有简单的方法?
附带问题:如何仅禁用mod_deflate?这是最大的坏蛋。我想在我的脚本中内部处理压缩。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
1.我认为不可能卸载已经加载的模块。这就是我在#1 上能说的全部内容。
2. 让我们将此代码放入 .htaccess 中:
这将压缩 .html 文件(当然,只要 s 足够大)。
现在,让我们将
html
添加到排除的扩展列表中:现在在浏览器中重新加载相同的 html 文件(确保浏览器实际上是新鲜加载的(应该是 200 响应),而不是从缓存或通过 304 Not Modified)回复)。现在它发送的 html 文件根本没有压缩。 Firebug 确认:压缩后只有 480 字节,未压缩数据为 11.6 KB(html 文件基本上是重复 20 次左右的单段文本,因此压缩效果非常好)。
我确信您可以非常轻松地根据您的需要对其进行修改(在我的服务器上,全局未启用压缩 - 这是我在需要时使用的代码 - 因此不幸的是,我无法为您提供 100% 准确的代码)。例如:
1. I think it is not possible to unload already loaded module. That's all what I can say on #1.
2. Let's put this code in .htaccess:
This will compress .html files (as long s it is big enough, of course).
Now, let's add
html
to the list of excluded extensions:Now reload the same html file in browser (make sure browser actually loads it fresh (should be 200 response) and not from cache or via 304 Not Modified response). It now sends html file with no compression at all. Firebug confirms: only 480 bytes when compressed and 11.6 KB of uncomressed data (the html file is basically a single paragraph of text repeated 20 or so times, hence the very good compression).
I'm sure you can modify it to your needs very easily (on my server compression is not enabled globally -- that is the code I use when I need it -- so I cannot provide 100% exact code for you, unfortunately). For example:
您可以通过在配置中根本不包含相关模块的 LoadModule 指令来阻止模块被加载。
You can prevent a module from being loaded in the first place by simply not having a LoadModule directive for the module in question in your configuration at all.