我已经在我的站点的 .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/