ASP 中,我们习惯使用 Response.Redirdect 来实现页面的跳转,但是这种跳转方式的状态是 302 的,属于临时跳转,对于搜索引擎来说,是一种不友好的重定向方式。
ASP 3.0 中,有了另一种方式,即 Response.Transfer 。关于这个,可以查询相关的信息。
我们这里要讨论的是 301 跳转,例如下面的代码:
- <%@ Language="VBScript" %>
- <%
- Response.Status = "301 Moved Permanently"
- Response.AddHeader "Location", "http://www.cdsc.com.cn"
- %>
假设有域名 cdsc.com.cn 和 wetyoier.cn ,分别针对同一个空间中的 cdsc_com.cn 和 wetyoier_cn 两个目录,那么怎么通过两个域名来自动确定访问哪个目录呢?请看下面的代码:
- <%
- Dim strHost = LCase(Request.ServerVariables("HTTP_HOST"))
- Response.Status = "301 Moved Permanently"
- Select Case strHost
- Case "cdsc.com.cn"
- Response.AddHeader "Location",
- "http://cdsc.com.cn/cdsc_com.cn/"
- Case "wetyoier.cn"
- Response.AddHeader "Location",
- "http://wetyoier.cn/wetyoier_cn/"
- Case Else
- Response.AddHeader "Location",
- "http://wetyoier.cn/wetyoier_cn/"
- End Select
- %>
另外关于这个的应用,就是在音乐播放或者下载中,针对浏览器或客户代理类型进行判断,从而选取对应的操作。例如限制只能使用 FlashGet 下载等等。