网址转向方法主要包括:301重定向,302重定向,编程重定向,PHP/ASP/CGI转向,META REFRESH网页META刷新等。302重定向可能会有URL规范化问题。
实现301重定向
1、Apache下301重定向配置
修改.htaccess文件,输入下列内容(需要开启mod_rewrite),具体方式请Google,网上有很多文章
如果你用的是 Windows主机,应该在控制面板做301转向设定。
一般来说只使用HTML无法做301重定向。在HTML里只能做JS或META REFRESH,但不是301转向。而如果用JS跳转就属于302了,而不是正常返回码为:301。具体大家可以使用这个工具来查看结果:
http://www.seoconsultants.com/tools/check-server-headers-tool/
2、javascript的301重定向代码
<script language=javascript>
if (document.domain =='mxyge.cn')
this.location = "http://www.huliye.org" + this.location.pathname + this.location.search;
</script>
3、ASP的301重定向代码
<%Response.Status="301 Moved Permanently"
Response.AddHeader "Location"," http://www.huliye.org"
Response.End
%>
4、JSP的301重定向代码
<%
response.setStatus(301);
response.setHeader( "Location", "http://www.huliye.org" );
response.setHeader( "Connection", "close" );
%>
5、PHP的301重定向代码
<?php
Header("HTTP/1.1 301 Moved Permanently");
Header("Location: http://www.huliye.org");
?>
6、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.huliye.org");
}
</script>
7、CGI Perl的301重定向代码
$gb = new CGI;
print $gb->redirect(http://www.huliye.org);