.htaccess - 如何使用 HTTP 禁用 HSTS header ?

标签 .htaccess http https preload hsts

我已经在我的站点的 .htaccess 中插入了以下内容,以便进入 HSTS preload list。 :

<ifModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"   
</ifModule>

问题是当我提交我的网站时,我得到:

Warning: Unnecessary HSTS header over HTTP. The HTTP page at http: //fabriziorocca.it sends an HSTS header. This has no effect over HTTP, and should be removed.

目前我在 .htaccess 中使用以下内容以从 http 切换到 https:

RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

我该如何解决这个问题?

提前谢谢你。

最佳答案

在您的重定向规则下方添加代码:

Header always set Strict-Transport-Security "max-age=31536000; 
includeSubDomains; preload" env=HTTPS

关于.htaccess - 如何使用 HTTP 禁用 HSTS header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38235475/

相关文章:

url - https url 的子域部分是否安全?

python - 如何使用 HTTP "Host" header (使用 GoLang)定位特定的应用程序服务器

.htaccess - 使用 gulp 复制 .​​htaccess(一个点文件)失败

javascript - 如果用户直接在 URL 中输入页面名称,如何重定向页面

.htaccess - 301使用htaccess将子域重定向到另一个域

ruby-on-rails - 获取 HTTPS 连接以使用本地 Rails 应用程序和 nginx?

wordpress - 从本地主机到rest api结果的认证CORS错误

python - 我正在尝试安装 python 模块 HTTP

android - 带有 cookie 的 HttpPost 请求

node.js - 我应该发送多少个并发 http 请求?