Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (39 sloc) 761 Bytes
permalink display title tags emotag date comment layout component
/posts/anti-http-hijacking
normal
简单防HTTP劫持
前端
2018-07-30 05:51:37 UTC
true
post

对于http劫持,直接上https当然是最佳办法。以下是一个简单办法,效果也不错,当然我全站https以后这些代码就删掉了,放这里留作备份。

来自:http://www.cnblogs.com/coco1s/p/5777260.html

<!--!DOCTYPE html>
<html>
<head></head>
<body></body>
</html-->
<html>
<head></head>
<body></body>
</html>
<!--!DOCTYPE html>
<html>
<head></head>
<body></body>
</html-->
<script>
if (self != top) {
  // 我们的正常页面
  var url = location.href;
  // 父级页面重定向
  top.location = url;
}
</script>