301重定向实现代码及作用

武宁网站制作-研究了很久关于页面永久性转移(301永久重定向)是一种非常重要的自动转向技术。在更换域名的时候起着不可替代的作用,他不仅可以实现网页的批量指定转跳,还可促进搜索引擎优化效果。301重定向是网址重定向最为可行的一种办法。当网站的域名发生变更后,搜索引擎只对新网址进行索引,同时又会把旧地址下原有的外部链接如数转移到新地址下,从而不会让网站的排名因为网址变更而收到丝毫影响。当然各个搜索引擎对301的处理方式是不一样的。下面的小编为大家详细讲解一下常用的asp,jsp,asp.net,php的设置方法:
asp:
response.status=301 moved permanently
response.addheader location,http://www.f360f.com/
response.end
php:
header(http/1.1 301 moved permanently);
header(location:http://www.f360f.com/);
exit;
jsp:
<%
response.setstatus(301);
response.setheader( location, http://www.f360f.com/ );
response.setheader( connection, close );
%>
asp.net:
<script runat=server>
private void page_load(object sender, system.eventargs e)
{
response.status = 301 moved permanently;
response.addheader(location,http://www.f360f.com);
}
</script>
php:
<?php
$go=$_get['go'];//获取跳转页面链接部分,如thread-112-1.html,又如forum.php?fid=32等
header(http/1.1 301 moved permanently);//发送301状态,之后的所有跳转均为301
header('location:http://www.f360f.com/'.$go);//根据go参数跳转到对应页面
exit;
?>
上一个:【常德seo】如何设计网站模板的导航页面
下一个:2023年深圳企业网址定制流程
武宁网站建设,武宁做网站,武宁网站设计