本站测试通过
方法一:以下代码保存为首页文件
<script type="text/javascript">
var host = new Array();
var url = new Array();
var size = 0;
////////////////////////////////////// 需要修改部分
push(host, url, "wenrouge.com", "index.php");
push(host, url, "www.wenrouge.com ", "index.php");
push(host, url, "xxx.cn", "/abc");
push(host, url, "www.xxx.cn ", "/abc");
//////////////////////////////////////
var req_url = window.location.href;
for(i=0; i<size; i++)
{
if ( req_url.indexOf(host[i]) >= 0 )
{
window.location.href = url[i];
break;
}
}
function push(hostArray, urlArray, host, url)
{
hostArray[size] = host;
urlArray[size] = url;
size++;
}
function Array()
{
return this;
}
</script>
方法二:将以下代码保存为domain.js文件
switch(location.host){
case 'www.abcdefg.cn':
location.href="/abcdefg/"
case 'abcdefg.cn':
location.href="/abcdefg/"
break;
}
然后再首页开始加入:
<script language='javascript' src='domain.js'></script>
发表评论