天天看点

301永久重定向实现方式及302重定向

301,302 都是HTTP状态的编码,都代表着某个URL发生了转移。不同之处就是:

301 redirect: 301代表永久性转移(Permanently Moved),301重定向是网页更改地址后对搜索引擎友好的最好方法,只要不是暂时搬移的情况,都建议使用301来做转址。(推荐使用)

302 redirect: 302代表暂时性转移(Temporarily Moved ),在前些年,不少Black Hat SEO曾广泛应用这项技术作弊,目前,各大主要搜索引擎均加强了打击力度,象Google前些年对Business.com以及近来对BMW德国网站的惩罚。即使网站客观上不是spam,也很容易被搜寻引擎容易误判为spam而遭到惩罚。

meta fresh: 这在2000年前比较流行,不过现在已很少见。其具体是通过网页中的meta指令,在特定时间后重定向到新的网页,如果延迟的时间太短(约5秒之內),会被判断为spam。 

<meta http-equiv="refresh" content="0;url=http://forum.csdn.net" /> 

PHP下的301重定向

<?

Header( "HTTP/1.1 301 Moved Permanently" ) ;

Header( "Location: http://www.bloghuman.com " );

?

ASP下的301重定向

<%@ Language=VBScript %>

<%

Response.Status="301 Moved Permanently"

Response.AddHeader "Location"," http://www.csdn.net "

%>

ASP .NET下的301重定向

<script runat="server">

private void Page_Load(object sender, System.EventArgs e)

{

Response.Status = "301 Moved Permanently";

Response.AddHeader ("Location"," http://www.csdn.net ");

}

</script>

ColdFusion下的301重定向

<.cfheader statuscode="301" statustext="Moved permanently">

<.cfheader name="Location" value=" http://www.csdn.net ">

继续阅读