301转向怎么做?

发布:seo优化 | 分类:SEO技术 | 引用:0 | 浏览:

13 Dec 2008

301转向怎么做?

这个问题问了很多人

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

现在知道的有2类,一类是在web服务软件上做,还有就是在程序里面做

先说在web服务软件

如果是iis:
打开internet信息服务管理器,在要重定向的网页或目录上按右键[separator]

选中“重定向到URL”
在对话框中输入目标页面的地址
选中“资源的永久重定向”
点击“应用
如果是apache方法多一些,也方便一些
如果要把访问www.juhui.com的请求全部301到www.juyimeng.com


<VirtualHost www.juhui.com>
Redirect 301 / http://www.juyimeng.com/
CustomLog logs/redir "%h %l %u %t &#92;"%r&#92;" %>s %b &#92;"%{Referer}i&#92;" &#92;"%{User-agent}i&#92;""
</VirtualHost>

上面的
Redirect 301 / http://www.juyimeng.com/
可以写为
Redirect permanent / http://www.juyimeng.com/

也可以用apache的.htaccess,怎么使.htaccess起效,点这里
.htaccess文件的内容

RewriteEngine on
rewriterule abc&#92;.html /index&#92;.html [R=301]
其总用是把abc.html301到index.html

用程序来做

用PHP来做301重定向

[quote]<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.test.com" );
?>


用JSP (Java)来做301重定向

文<%
response.setStatus(301);
response.setHeader( "Location", "http://www.test.com/" );
response.setHeader( "Connection", "close" );
%>

用CGI PERL 来做301重定向

$q = new CGI;
print $q->redirect("http://www.test.com/");
用ASP来做301重定向

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently";
Response.AddHeader("Location","http://www.test.com/");
%>
用ColdFusion 来做301重定向

<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="http://www.test.com">
用ASP .NET Redirect来做301重定向

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.test.com");
}
</script>
用Ruby on Rails Redirect来做301重定向

def old_action
headers["Status"] = "301 Moved Permanently"
redirect_to "http://www.test.com/"
end
html的meta refresh和javascript也可以转向

<meta http-equiv="Refresh" content="0; url=http://test.com/page.html">

<script>
window.location="http://www.test.com/test.html";
</script>
[/quote]

但是上述的方法不推荐

如果要Redirect的源url是html这种结尾也可以,改apache的配置,把html扩展名的文件当Php或者其他脚本来处理就可以了
AddType application/x-httpd-php .html
AddType application/x-httpd-php .htm

上述改造是否成功,可以用httpwatch来查看

  • 相关文章:

1评论 - 301转向怎么做?

Avatar

80后

2009-4-29 8:59:29

这个还是不太会

发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于

徐倩产品设计博客www.hongren.org,SEO技术交流学习、网站运营、网络营销、产品设计。在互联网这条长路上找到产品方向作为以后职业目标,博客上点点滴滴记录工作三年来的心路历程。也希望在此结交更多志同道合的朋友一起交流学习。

我的图片

日历


控制面板

最近发表

最近留言