防止网站被镜像

⒈添加到 header.php 中适当位置

注:部分镜像站点会屏蔽 JS 代码,所以对部分镜像站点无效

1
<script type="text/javascript">if (document.location.protocol != "https:" && navigator.userAgent.indexOf("MSIE 6.0") < 0 ) { location.href = location.href.replace(/^http:/,"https:");}if (document.location.host != "1han.wiki") { location.href = location.href.replace(document.location.host,'1han.wiki');} </script>

⒉添加到主题的 functions.php 最后一个?> 之前

1
2
3
4
5
add_action('wp_head','kimsom_reverse_proxy_defense', 99);
function kimsom_reverse_proxy_defense(){
$currentDomain = '"1han" + ".wiki"';
echo '<img style="display:none" id="inlojv-rpd" src="" data-url=".home_url()." onerror="\'var" str0="true" ishttps="true" document="true" location="true" protocol="true" true:false="true" if="true" var="true" str1="http" else="true" str2=".$currentDomain." str3="true" href="location.href.replace(document.location.host,'." currentDomain="true">';
}

记得修改成自己域名

🔰本文标题: 防止网站被镜像

🔞本文链接: https://193.gs/fangzhiwangzhanbeijingxiang/index.html

🌡️本文总热度