apache 如何在 apache2 中禁用 mod_deflate?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1922934/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 18:31:03  来源:igfitidea点击:

How to disable mod_deflate in apache2?

apacheapache2mod-deflate

提问by wakandan

How can I disable mod_deflate in Apache2

如何在 Apache2 中禁用 mod_deflate

  • For files in a specific directory
  • 对于特定目录中的文件

OR

或者

  • For all files that have extension of, for example .py?
  • 对于所有扩展名为 .py 的文件?

回答by Gumbo

You could set the environment variable no-gzipfor that directory/type of file:

您可以为该目录/文件类型设置环境变量no-gzip

# for URL paths that begin with "/foo/bar/"
SetEnvIf Request_URI ^/foo/bar/ no-gzip=1

# for files that end with ".py"
<FilesMatch \.py$>
    SetEnv no-gzip 1
</FilesMatch>

回答by ATM007

Quote from: scottlinux.com

自:scottlinux.com

Disable Compression: To disable compression in Apache, typically you just need to disable the module mod_deflate...

禁用压缩:要在 Apache 中禁用压缩,通常您只需要禁用模块 mod_deflate...

Debian/Ubuntu:

Debian/Ubuntu:

$ sudo a2dismod deflate
Module deflate disabled.
Run '/etc/init.d/apache2 restart' to activate new configuration!

$ sudo /etc/init.d/apache2 restart

回答by ATM007

Don't know if this is a general solution, but it worked for me at least, to turn of mod_deflate for .py-files within a .htaccess file in a certain folder:

不知道这是否是一个通用的解决方案,但它至少对我有用,在某个文件夹中的 .htaccess 文件中为 .py-files 关闭 mod_deflate:

SetEnvIfNoCase Request_URI "\.py$" no-gzip dont-vary