js实现域名判断后跳转到指定网址

js实现域名判断后跳转到指定网址,也适用于同一虚拟空间放多个网站:

<script>
       try
           {
               if(self.location == "http://apple.ya37.com/")
               {
                   top.location.href = "http://ya37.com/apple/";
               }
               else if(self.location == "http://girl.ya37.com/")
               {
                   top.location.href = "http://ya37.com/girl/";
               }
               else if(self.location == "http://simple.ya37.com/")
               {
                   top.location.href = "http://ya37.com/simple/";
               }
               else {document.write ("错误的访问地址")}
           }
       catch(e){ }
   </script>

看明白了吧,如果访问者输入的域名是"http://apple.ya37.com/"的话,就访问"http://ya37.com/apple/"

posted on 2014-12-08 22:11  探灵档案  阅读(840)  评论(0编辑  收藏  举报

导航