网站动静态页面权重转移(301跳转)

网络技术 2309 0 2011-09-06

网站动静态页面权重转移(301跳转)
动态页面进行301重定向,权重转移我想大家都很清楚了,代码如下,重温一下.

<!--ASP:-->
<%
Response.Status="301 Moved Permanently"    
Response.AddHeader "Location","http://www.hilo8.com"    
Response.End
%>

<!--PHP:-->
<?php
if ( $_SERVER['SERVER_NAME'] == 'hilo8.com'){
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.hilo8.com");
exit();
}
?>

如果我想把 http://hilo8.com 权重转移到 http://www.hilo8.com 该怎么操作呢?

很简单,情况下面代码.

<!--ASP:-->
<%
if Request.ServerVariables("Http_Host") ="hilo8.com" then
Response.Status="301 Moved Permanently"    
Response.AddHeader "Location","http://www.hilo8.com"    
Response.End
end if
%>

<!--PHP:-->
<?php
if ( $_SERVER['SERVER_NAME'] == 'hilo8.com'){
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.hilo8.com");
exit();
}
?>

<b>我想做完美的301跳转,也就是子页面跳转到对应的子页面怎么操作呢?</b><br>
<b>同级域名跳转例如:
http://www.hilo8.com/Record/69.html
http://www.58try.com/Record/69.html<br>

<%
netpath = "http://www.hilo8.com"
netpath = netpath&Request.ServerVariables("PATH_INFO")
response.write netpath
Response.Status="301 Moved Permanently" 
Response.AddHeader "Location",netpath 
Response.End
%>

非同级域名跳转例如:
http://hilo8.com/Record/69.html
http://www.58try.com/Record/69.html
也不难,如下.

<%
Dim dm,sn
dm=Request.ServerVariables("Server_name")  '获取域名
'这里的3是指www的长度
if left(dm,3)<>"www" then
Response.Status="301 Moved Permanently" 
Response.AddHeader "Location", GetUrl()
Response.End
end if

'获取当前Url参数的函数
Function GetUrl()
  Dim ScriptAddress,Servername,qs
  ScriptAddress = CStr(Request.ServerVariables("SCRIPT_NAME"))
  Servername = CStr(Request.ServerVariables("Server_Name"))
  qs=Request.QueryString
  if qs<>"" then
  GetUrl ="http://www."& Servername & ScriptAddress &"?"&qs
  else
  GetUrl ="http://www."& Servername & ScriptAddress
  end if
End Function
%>


在我们遇到了静态页面的时候如何做权重转移呢?

很多时候因为网站改版或者什么其他原因,有些静态页面已经有很高的PR了,如何把这些高PR的静态页面转移到其他网页上呢.

需要对一些静态页面进行转移,一个网页能否算是成功读取,服务器会给客户端返回一个成功读取的参数,一般是200错误.说到这里可能有些朋友会有点晕,为什么是错误呢,这里指的200错误是指服务器返回值,例如:当打开某网页,网页不存在时会返回404错误,权限不足时会返回401错误等等.

这里做的静态页面权重转移就是要利用404错误.

建一个error.asp文件.指定404错误跳转到error.asp文件.

然后error.asp文件分析网址,得到旧网址,再通过上面的301代码跳转到新的网址.


还有一种方法就简单点.直接用元描述跳转

[CODE_LITE]
<meta http-equiv="refresh" content="10;URL=http://www.hilo8.com">

已经有网友成功验证,这个方法是可行的.效果比动态的301跳转来的慢一些.

上一篇:没有了

下一篇:为什么QQ空间有时候打不开呢?

讨论数量:0

请先登录再发表讨论。 2024-04-16

天涯网魂
3 杠 5 星
TA 的文章
TA 的随言
TA 的资源链