可以将
http://www.aaaaaaa.com/aa/aa.php?abc=123#456
http://www.bbbbbbb.net/aa/aa.php?abc=123#456
转换(切换)成 http://www.chaoyumi.cn/
也就是当你的网站绑定了多个域名,想让其它域名跳转到一个域名上,又想让域名后面的URI地址不变。
http://www.aaaaaaa.com/aa/aa.php?abc=123#456
http://www.bbbbbbb.net/aa/aa.php?abc=123#456
转换(切换)成 http://www.chaoyumi.cn/
也就是当你的网站绑定了多个域名,想让其它域名跳转到一个域名上,又想让域名后面的URI地址不变。
<script language=
"javascript" type=
"text/javascript">
<!--
var abc = "www.chaoyumi.cn";
var qwe = window.location.host;
if(qwe != abc){
window.location = "http://" + abc + window.location.pathname + window.location.search + window.location.hash;
}
-->
</script>
<!--
var abc = "www.chaoyumi.cn";
var qwe = window.location.host;
if(qwe != abc){
window.location = "http://" + abc + window.location.pathname + window.location.search + window.location.hash;
}
-->
</script>
将上面代码放到
<head></head>
之间即可(注意:将我的域名换成你自己的域名)。
其实这段代码很简单,只使用到 JavaScript 的 Location 对象和 if 语句,如想实现相关的功能可查阅:
http://www.w3school.com.cn/htmldom/dom_obj_location.asp
转载于:https://blog.51cto.com/adminroad/241117