js实现域名判断后跳转到指定网址,也适用于同一虚拟空间放多个网站:
<script> try { if(self.location == "http://aaa.com/") { top.location.href = "http://xxx.com/aaa/"; } else if(self.location == "http://bbb.com/") { top.location.href = "http://xxx.com/bbb/"; } else if(self.location == "http://ccc.com/") { top.location.href = "http://xxx.com/ccc/"; } else { document.write ("错误的访问地址") } } catch(e){ } </script>
看明白了吧,如果访问者输入的域名是"http://aaa.com/"的话,就访问"http://xxx.com/aaa/"。