Written on 2009年5月5日 @ 20:12 | by spirit | Tags: 301 SEO | 浏览:
若转载请注明出处: Spirit's Home
本文地址: http://www.7788sky.cn/post/asp_php_301_head_redirect.html
301重定向可促进搜索引擎优化效果
从搜索引擎优化角度出发,301重定向是网址重定向最为可行的一种办法。当网站的域名发生变更后,搜索引擎只对新网址进行索引,同时又会把旧地址下原有的外部链接如数转移到新地址下,从而不会让网站的排名因为网址变更而收到丝毫影响。同样,在使用301永久性重定向命令让多个域名指向网站主域时,亦不会对网站的排名产生任何负面影响。
用.htaccess文件来进行301重定向,如果空间不支持.htaccess文件,那么我们还可以通过php/asp代码来进行301重定向。
PHP:
在 index.php 的最顶部加入以下几行:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.7788sky.cn/");
exit();
?>
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.7788sky.cn/");
exit();
?>
ASP:
在 index.asp 或 default.asp 的最顶部加入以下几行:
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.7788sky.cn/"
Response.End
%>
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.7788sky.cn/"
Response.End
%>
若转载请注明出处: Spirit's Home
本文地址: http://www.7788sky.cn/post/asp_php_301_head_redirect.html
1 Response to “asp、php实现301跳转重定向”
By GFWed.com on 2009-5-5 20:28:51| http://gfwed.com
Linux 有 .htaccess 功能的,呵呵。不需要这个代码了。