换域名后跳转至新域名对应的页面 网站目录改后跳转至新目录

换域名后跳转至新域名对应的页面 网站目录改后跳转至新目录(ASP实现)
原来的域名就要过期了,现在注册了新的,但百度搜索的连接就不能用了,这就考虑到跳转到新域名的问题.这个跳转只针对Asp,有两种方法,
一、简单的跳转至新域名,作用是把原域名的网址全部跳转至指定的某个网址,这样原来的文章就不太好找了。

二、域名完全对应的跳转,能完全保留原网址。
效果:原网址为www.111.com,新网址为www.222.com。
那么访问http://www.111.com/bbs/dispbbs.asp?BoardID=2&id=63 时就能自动跳转至http://www.222.com/bbs/dispbbs.asp?BoardID=2&id=63 ,保证访问连接的有效性。

后补第三种,更简单。

以下是具体设计

第一种:程序代码

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
'Response.Redirect "index.html"
Dim myhost
myhost = Request.ServerVariables("SERVER_NAME")
'Response.Write myhost
if instr(myhost,"222.com")>0 then
      'Response.Write instr(myhost,"222.com")
      Response.redirect "index.html"
      Response.End
end if    
'上面部分没用
if instr(myhost,"111.com")>0 then '判断是否是旧网址111.com  
     'Response.Write instr(myhost,"111.com") '自己做试验用的
      Response.redirect "http://222.com/index.html"      '跳转至新域名
      Response.End
end if
%>

第二种:程序代码
<%
Dim myhost,urlstr,query_string,url      '定义变量,可以不用.不过要想成为好的程序员,还是要养成好的习惯
myhost = Trim(Request.ServerVariables("SERVER_NAME"))     '取得网站的名字:如www.xi-s.cn
urlstr = Trim(Request.ServerVariables("URL"))                         '取得网站文件:如/blog/article.asp
query_string = Trim(Request.ServerVariables("QUERY_STRING"))'取得查询字符串:如id=8或者id=8&type=2
if query_string<>"" then
      '判断查询字符串是否为空.如果不为空,就要加上一个”?”
     '当然,最终地址还是要加上你的目录.如果采用的防盗链功能.我不知道这样行不行.如果你遇到这样的问题.我们可以一起研讨下.如果你有解决方法.希望你能共享一下.互联网嘛.要体现一点精神才行.
     '"http"可以不要.
      url = "http://" & "www.xi-s.cn" & urlstr & "?" & query_string
else
      '否则就不用加”?”
      url = "http://" & "www.xi-s.cn" & urlstr
end if      
'Response.Write myhost

if instr(myhost,"snhome.cn")>0 then
      '所有注释都可以删除.我是为了测试和说明的方便放在这里的.
      'Response.Write myhost
      'Response.Write urlstr
      'Response.Write query_string
      'Response.Write url
%>
<html>
<head>
<title>本网站启用新域名</title>
<script language="javascript">
var i;
function go()
{
     bar_width = document.getElementById("bg").clientWidth;
     i = bar_width;
     setTimeout('start();',100);
}
function start()
{
     if(i-->0)
     {
      ps.style.width = i;
      bn.innerHTML = Math.floor((bar_width-i)/bar_width*100)+"%";
      setTimeout('start();',15);
     }
     else
     {
      location.href="<%= url %>";
     }
}

</script>
<style type="text/css">
#bg {
filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr=#FFFF00, EndColorStr=#FF0000);
width:300px;
height:20px;
border:1px solid black;
z-index:0;
float:right;
position:absolute;
}
#ps {
float:right;
background-color:#FFFF00;
width:100%;
height:20px;
}
#bn {
position:absolute;
text-align:center;
width:100%;
height:20px;
cursor:default;
top: 4px;
}

body,td,th {
font-size: 12px;
color: #006600;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body onLoad="go();">


<table height="366" border="0" align="center" cellpadding="0" cellspacing="0">
     <tr>
       <td width="200"> </td>
       <td width="300" height="210"> </td>
       <td width="200"> </td>
     </tr>
     <tr>
       <td> </td>
       <td height="71" valign="middle"><div id="bg"><div id="ps"></div><span id="bn">0%</span></div></td>
       <td> </td>
     </tr>
     <tr>
       <td colspan="3" align="center"><p>本站启用新域名 稍候<font color=red>跳转至您检索的页面对应的新网址</font><br>
         <br>
         以下网址是您将要进入的页面 如不能跳转请点击进入<br>
         <a href="<%= url %>"><%= url %></a></p>
       本站新网址:<a href="http://www.xi-s.cn">http://www.xi-s.cn</a>       </td>
     </tr>
</table>
</body>
</html>
<%
Response.End
end if
%>


[本日志由 月神 于 2009-03-10 05:26 PM 编辑]
文章来自: baidu.com
引用通告: 查看所有引用 | 我要引用此文章
Tags: 跳转 新目录
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.