asp学习网: 首页 >> 程序参考 >> 优化oblog二级域名跳转

优化oblog二级域名跳转

Oblog4.6二级域名的跳转与搜索的优化

4.6的用户二级域名,是通过站点根目录下的default.asp进行跳转的。在default.asp文件中,主要使用<frameset>标签,源码如下:

<!--#include file="inc/inc_syssite.asp"-->
<%
Dim From,gourl,turl
From = LCase(Request.ServerVariables("HTTP_HOST"))
gourl= LCase(oblog.CacheConfig(3))
turl = Replace (gourl,"http://","")
turl = Left(turl, InStrRev(turl, "/")-1)
If From = turl Then
Response.Redirect(gourl&"index.asp")'此处为网站首页地址
Else
Response.Write( "<frameset><frame src="""&gourl&"blog.asp?domain="&from&"""></frameset>")
End If
Set oblog= Nothing
%>


大家可以看到,这首先从用户输入地址(如:http://myblog.youtx.net)取得用户名”myblog”,然后通过框架标签"<frameset>”跳转到"&gourl&"blog.asp?domain=myblog”,其中gourl为你设置的域名变量?。大家知道,<frameset>框架标签,搜可能或者不允许这种跳转。这就给我们站点在搜索引擎收录有很大的影响。

在网上查了一下,找到这么一段文字

asp3.0给了我们一个全新的跳转方法:Server.Transfer。其他像response.redirect,:<meta HTTP-EQUIV=REFRESH C>都会产生两次调用,耗费很长时间,而且搜索引擎可能不支持这种跳转,或者不允许这种跳转。server.transfer有点像include,直接将目标页面的代码拿进来取代当前页面执行,在客户端看来仅一次调用,就是执行当前页面。不过server.transfer仅支持相对路径的跳转,不能跳转到其他的网站!跳转页面的内容也仅限于asp和html。经过测试,我发现response.redirect的状态码是302,而meta的方法状态码是200,它是靠浏览器跳转的。301属于永久性重定向,而302则属于临时性重定向。302按照google的原则是不能长期使用的,跳转后的内容不会被采用。asp跟php的301重定向方法:ASP:Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://www.yoursite.com/" Response.EndPHP:header("HTTP/1.1 301 Moved Permanently");header("Location:http://www.yoursite.com/");exit();
参考: http://www.aspxuexi.com/aspbasic/server/2006-8-12/969.htm

于是,对于原文件进行修改,如以下:

<!--#include file="blog/inc/inc_syssite.asp"-->
<%
Dim From,gourl,turl,Url,Retrieval,strreturn,i,thischarcode,nextcharcode,Html
From = LCase(Request.ServerVariables("HTTP_HOST"))
Response.Status="301 Moved Permanently"
if left(from,5)="blog." then
Response.AddHeader "Location","blog/index.Html"
end if
if left(from,4)="www." or left(from,6)="txyou."or left(from,6)="youtx." or left(from,4)="203." Then ‘这里根据自己的需要进行设置或添加
Response.AddHeader "Location","index.asp" ‘转向你首页
else
Response.AddHeader "Location","http://www.txyou.net/blog/blog.asp?domain="&from ‘跳转到用户的首页。
End if
Set oblog= Nothing
%>

说明一点,用<frameset>标签,可以隐藏真实的地址,不管用户打开哪一个页面,地址都显示HTTP://MYBLOG.YOUTX.NET而不是真实的地址,用Response.AddHeader跳转,显示的是真实地址。

说明一下我的站点配置,以便大家参考修改:
域名:WWW。TXYOU。NET WWW。YOUTX。NET 天下游 游天下 中国古城网
I P : 203.xxx.xxx.xxx.xxx
Blog目录:blog/
BBS目录:BBS/
分别设置了泛解析*.txyou.net *.txyou.net 这个在域名商那里可以设置

以上使用了我的真实域名等情况,以便于让大家容易修改。

End 
 

 

from:asp学习网/title:优化oblog二级域名跳转/ time:2007-11-7 16:54:32

本文主题oblog

asp教程 ©2006-2007 aspxuexi.com | 关于站点 | 版权隐私 | 站内搜索
复制或者翻版 请于夜间进行