【发布时间】:2022-01-11 12:38:53
【问题描述】:
我正在尝试重定向
http://dev.example.com
到
https://www.example/dev
在我的 htaccess 中使用此代码:
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^dev.example.com
RewriteRule ^(.*)$ https://www.example.com/dev/$1 [L,NC,QSA]
RewriteCond %{HTTP_HOST} ^dev.example.com$ [NC]
RewriteRule ^((?!dev).*)$ /dev/$1 [NC,L]
一家安全评估公司抱怨以下问题:
HTTP 站点以无法使用 HTTPS 和 HSTS 标头保护的方式将用户重定向到新 URL。这使用户容易受到中间人攻击者的攻击,这些攻击者可以将他们重定向到目标网站的欺诈/欺骗版本。
我该怎么做?第一次重定向
http://dev.example.com 到 https://dev.example.com
然后
https://dev.example.com 到 https://www.example.com/dev?
【问题讨论】:
-
您真的要在这个阶段实施 HSTS 吗?或者您只是想让重定向符合 HSTS 标准?确认一下,您是否要将 everything 从
dev.example.com重定向到www.example.com?只是你的指令目前没有这样做。 -
@MrWhite 我想将所有内容从 dev.example.com 重定向到 www.example.com/dev 并使其符合 HSTS。这可能吗?
标签: .htaccess subdomain subdirectory hsts