ASP实现 URL 转发

2021 年 8 月 3 日1500

URL转发功能是域名注册后的增值服务。所谓URL转发,是通过服务器的特殊设置,将访问您当前域名的用户引导到您指定的另一个网络地址。例如,URL转发可以让用户在访问http://http://www.zjjv.com//时,自动转向访问http://http://www.zjjv.com///somedir/other.htm

但通过URL转发访问网站不是一种非常理想的网站访问方法,由于URL转发服务器受攻击的概率较高,影响URL的正常转发。

为了避免这种情况,我们可以通过另外一种方法实现URL的功能, 例如我们希望键入 http://www.zjjv.com/ 能直接访问到 http://http://www.zjjv.com///help/default.asp

那么

首先在 http://www.zjjv.com/ 的网站上绑定 http://www.zjjv.com/ :

然后在 http://www.zjjv.com/ 网站的默认首页(例:default.asp或者index.asp)中加入以下代码:

<%

dim url

url=request.ServerVariables("HTTP_HOST")

if url="http://www.zjjv.com/" then

response.Redirect("http://http://www.zjjv.com///help/default.asp")

end if

%>

如果要实现隐藏转发,可以使用框架实现,代码如下:

<%

dim url,redirectUrl

url=request.ServerVariables("HTTP_HOST")

if url="http://www.zjjv.com/" then

redirectUrl="http://www.zjjv.com//help/default.asp"

end if

%>

<frameset framespacing="0" border="0" rows="0,100%" frameborder="0">

<frame name="top" scrolling="no" noresize src="nothing.htm" marginwidth="0" marginheight="0">

<frame name="main" src="<%=redirectUrl%>" marginwidth="0" marginheight="0" scrolling="auto">

<noframes>

<body>

<p>此网页使用了框架,但您的浏览器不支持框架。</p>

</body>

</noframes>

</frameset>

0 0