通过htaccess禁用Apache http2公告 [英] Disable Apache http2 announce via htaccess

查看:389
本文介绍了通过htaccess禁用Apache http2公告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在共享主机上有一个网站,在每个页面请求上使用以下HTTP标头进行响应:

I have a website on a shared host, responding with these HTTP headers on each page request:

HTTP/1.1 200 OK
Date: Thu, 21 Sep 2017 14:34:46 GMT
Server: Apache
X-Powered-By: PHP/5.6.31
Access-Control-Allow-Origin: *
Upgrade: h2,h2c
Connection: Upgrade, Keep-Alive
Keep-Alive: timeout=5, max=400
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

您注意到,有升级标头,这是Apache宣布的有关HTTP2协议支持的消息。

As you note, there is the Upgrade header that is an announce from Apache about the support of HTTP2 protocol.

出于某种原因,我需要禁用Apache的这种行为,以便发送没有 Upgrade 标头的响应。

For some reason, I need to disable this behavior of Apache, in order to send responses without the Upgrade header.

谁知道如何从.htaccess文件中禁用它?
我已经找到了此解决方案:

Who knows how to disable it from the .htaccess file? I've already found this solution:

Header unset Upgrade

但这不是一个好方法,因为有时我需要从我的输出一个自定义的 Upgrade 标头代码(需要广播固件升级到某些热敏打印机设备)。

But it's not the good one, since sometimes I need to output a custom Upgrade header from my code (needed to broadcast a firmware upgrade to some thermal printer devices).

谢谢

推荐答案

尝试使用以下配置将其关闭: https: //httpd.apache.org/docs/2.4/mod/mod_http2.html#h2upgrade

Try turning it off with this config: https://httpd.apache.org/docs/2.4/mod/mod_http2.html#h2upgrade.

或者,对于仅.htaccess的解决方案,请使用标题编辑功能:

Alternatively, for a .htaccess only solution, use the Header edit functionality:

Header edit Upgrade (.*)h2,h2c(.*) "$1$2"

请注意,这可能会为您留空升级头,并且您可能必须根据服务器确切显示的内容(例如,多余的逗号)来更改配置。

Note this may leave you with an empty upgrade header, and you may have to change the config depending on what exactly is shown by your server (e.g. extra commas).

这篇关于通过htaccess禁用Apache http2公告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆