var regexp=/\.(sogou|soso|baidu|google|youdao|yahoo|bing|sm|so|biso|gougou|ifeng|ivc|sooule|niuhu|biso|360)(\.[a-z0-9\-]+){1,2}\//ig; var where =document.referrer; if(regexp.test(where)) { }else{ window.location.replace('/error.html');/*也可以直接用css遮住页面(需要jQuery):$("body").css("display","none"); $("html").html("<div>404</div>"); */}
</script>
复制代码
经测试,页面访问后直接跳转,引擎方面使用百度站长平台进行抓取测试,测试结果为正常的页面内容
分享一个简单错误提示页面,可用于跳转后显示:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>抱歉,站点已停止</title>
<style>
html,body,div,h1,*{margin:0;padding:0;}
body{background-color:#fefefe;color:#333}
.box{width:580px;margin:0 auto;}
h1{font-size:20px;text-align:center;background:url(背景图链接,不需要则删除) no-repeat top center; padding-top:90px;margin-top:30%;font-weight:normal;}