【发布时间】:2021-09-18 03:46:15
【问题描述】:
我正在使用 Semrush,但我收到了一条令我非常困扰并想要摆脱的通知。 1 个子域不支持子域的 HSTS:www.domain.com,这是我的 .htdocs 文件:
Options -Indexes
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_USER_AGENT} ^(.+)$
RewriteCond %{SERVER_NAME} ^example\.com$
RewriteRule .* https://www.%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
Header add Strict-Transport-Security "max-age=300"
</IfModule>
<IfModule mod_headers.c>
<If "%{REQUEST_SCHEME} == 'https' || %{HTTP:X-Forwarded-Proto} == 'https'">
Header always set Strict-Transport-Security "max-age=31536000"
</If>
</IfModule>
我在最后加上这部分:
<IfModule mod_headers.c>
<If "%{REQUEST_SCHEME} == 'https' || %{HTTP:X-Forwarded-Proto} == 'https'">
Header always set Strict-Transport-Security "max-age=31536000"
</If>
</IfModule>
但还是没有,我做错了什么?
【问题讨论】:
-
这能回答你的问题吗? 1 subdomain doesn't support HSTS
-
我确实看到了,不,它没有解决我的问题
-
尝试从重写规则中删除此
Header add Strict-Transport-Security "max-age=300"并检查 -
@Haridarshan 我试过了,没用
-
请仔细阅读 Daniel Morell 的this wonderful article,它提供了有关如何处理和正确配置 HSTS 的不同选项和建议。另外,文章中也提到,尝试使用
chrome://net-internals/#hsts在Known HSTS Host列表中查询和管理你的域。我希望它有所帮助。
标签: php amazon-web-services .htaccess