吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 8821|回复: 4
收起左侧

[其他转载] 301跳转之网站动静态页面处理方式

   关闭 [复制链接]
wangfakun 发表于 2010-9-28 09:18
本帖最后由 wangfakun 于 2010-10-2 15:30 编辑
动态页面进行301重定向,权重转移我想大家都很清楚了,代码如下,重温一下.
<!--ASP:-->
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.52pojie.cn"
Response.End
%>
<!--PHP:-->
<?php
if ( $_SERVER['SERVER_NAME'] == '52pojie.cn'){
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.52pojie.cn");
exit();
}
?>
如果我想把 http://52pojie.cn 权重转移到 http://www.52pojie.cn 该怎么操作呢?
很简单,情况下面代码.
<!--ASP:-->
<%
if Request.ServerVariables("Http_Host") ="52pojie.cn" then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.52pojie.cn"
Response.End
end if
%>
<!--PHP:-->
<?php
if ( $_SERVER['SERVER_NAME'] == '52pojie.cn'){
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.52pojie.cn");
exit();
}
?>
<b>我想做完美的301跳转,也就是子页面跳转到对应的子页面怎么操作呢?</b><br>
<b>同级域名跳转例如:
http://www.52pojie.cn/Record/69.html
<A href="http://www.baoluowanxiang.com/Record/69.html
http://www.52pojie.cn/Record/69.html<br>
已经有网友成功验证,这个方法是可行的.效果比动态的301跳转来的慢一些.
<%
netpath = "http://www.52pojie.cn"
netpath = netpath&Request.ServerVariables("PATH_INFO")
response.write netpath
Response.Status="301 Moved Permanently"
Response.AddHeader "Location",netpath
Response.End
%>
非同级域名跳转例如:
http://52pojie.cn/Record/69.html
http://www.52pojie.cn/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.52pojie.cn”>

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

kgdydyygy 发表于 2010-9-28 09:27
这个是哪里用的代码
mause 发表于 2010-9-29 15:29
blackhat 发表于 2010-10-22 08:22
我想问一下.如果我想实现301跳转将52pojie.cn跳转到www.52pojie.cn
并且权重转移过去,虽然你这里有写.但是代码是写进首页还是宁外写进一个文件夹?
还有,在IIS里有个URL301跳转.那个要设置吗?可以把步骤说详细点吗?

<!--ASP:-->

<%

if Request.ServerVariables("Http_Host") ="52pojie.cn" then

Response.Status="301 Moved Permanently"

Response.AddHeader "Location","http://www.52pojie.cn"

Response.End

end if

%>
yixiangling 发表于 2010-11-26 16:20
头有点晕了。。。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-6-2 07:28

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表