如何做301转向

2008年04月27日 15:22 | SEO、技术相关研究及文章 | 标签: ,
      重定向是最有效的网页跳转方式,搜索引擎友好(Search Engine Friendly)。其实做一个重定向很简单,而且重定向的目标页将继承转出页面的搜索引擎排名,如果你需要修改网页名称或者转移网页路径,这是最安全的选择。在搜索引擎理解,“”这个代码表示的是“永久转向”。
你可以测试你网页转向的效果,下面介绍一些网页重定向的方法:


IIS中重定向

      打开Internet信息服务,右击你要跳转的文件夹或者文件,在弹出的右键菜单中选择属性弹出的对话框中,找到 “连接到资源是的内容来源” ,选择“重定向到URL”,在下面的文本框中输入要跳转到的页面同时,将”客户端将定向到” 下面的复选框 “资源的永久重定向”选上点击”应用”

ColdFusion中重定向
<.cfheader statuscode=”″ statustext=”Moved permanently”>
<.cfheader name=”Location” value=”
http://www.new-url.com“>

用PHP代码实现重定向
<?
Header( “HTTP/1.1 Moved Permanently” );
Header( “Location:
http://www.new-url.com” );
?>

用ASP代码实现重定向
<%@ Language=VBScript %>
<%
Response.Status=” Moved Permanently” Response.AddHeader “Location”, ”
http://www.new-url.com
%>

ASP .NET实现重定向
<script runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “ Moved Permanently”;
Response.AddHeader(”Location”,”
http://www.new-url.com“);
}
</script>

从一个老域名转移到新域名(htaccess重定向,只能在linux服务器下使用,并且确定Apache开启了Mod-Rewrite moduled)
在网站根目录下建立一个包含下面代码的.htaccess文件
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*)
http://www.newdomain.com/$1 [R=,L]

把yourdomain.com重定向到www.yourdomain.com(htaccess重定向,只能在linux服务器下使用,并且确定Apache开启了Mod-Rewrite moduled)
在网站根目录下建立一个包含下面代码的.htaccess文件
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$
http://www.domain.com/$1 [r=,nc]

当服务器为windows操作系统的时候,就用IIS重定向,为linux的时候用.htaccess

相关日志


文章标题:如何做301转向
链接地址:http://mylb.net.cn/2008/04/21.html

本页共有1 条留言


  1. 菜水母 .

    继续。。

想说点什么吗?