function isMatch(str1,str2)
{
var index = str1.indexOf(str2);
if(index==-1) return false;
return true;
}
if (isMatch(window.location.hostname,'www.123.com') == false){window.location.href="http://www.123456.com";}
代码在上面了,起到的作用是:判断域名是否为www.123.com,如果不是就跳转到www.123456.com。目前只能添加一个域名,需要支持多个域名,比如还有一个域名叫www.456.com,代码判断当前域名是否存在于www.123.com和www.456.com中,如果存在,则无操作,如果不存在则跳转到www.123456.com