【发布时间】:2017-05-01 18:30:36
【问题描述】:
我正在尝试将用户从 https://www.example.com 重定向到 https://example.com(因为 SSL 证书仅对后者有效),这在 Chrome 中使用此代码非常有效:
if(isset($_SERVER['HTTPS']) and $_SERVER['SERVER_PORT'] == 443){
// We are on https version
if(strtolower($_SERVER['SERVER_NAME']) == 'www.example.com'){
// Wrong domain: Redirect to safety
header('Location: https://example.com/', true, 301);
exit();
}else{
// We are safe
die('SSL certificate OK: Your credit card is now safe');
}
}else{
// Redirect to safety
header('Location: https://example.com/', true, 301);
exit();
}
但是,Firefox 拒绝重定向,并且一直显示通常的 INSECURE SITE:立即离开此页面,否则您的信用卡将被盗,等等。 警告仅此而已.是否有一些解决方法可以强制此 Firefox 首先重定向然后检查 SSL 证书,就像 Chrome 已经做的那样?
注意:我没有使用 IIS,所以我不需要检查 $_SERVER['HTTPS'] 的值,它按原样工作。
【问题讨论】:
标签: firefox https ssl-certificate