对不起,本站需要开启Javascript;请您打开该功能



使用.htaccess文件来进行301重定向,请见我的另外一篇文章《301重定向,域名更换后跳转到新域名》 
。 
如果空间不支持.htaccess文件,那么我们还可以通过php/asp代码来进行301重定向。 
为了将搜索引擎的记录更新到现在的域名上面,做了几个301重定向的东东,给大家分享一下. 
asp 301转向代码 
在 index.asp 或 default.asp 的最顶部加入以下几行: 
复制代码 代码如下:
<% 
Response.Status="301 Moved Permanently" 
Response.AddHeader "Location","http://www.jb51.net/" 
Response.End 
%> 
php 301转向代码 
在 index.php 的最顶部加入以下几行: 
复制代码 代码如下:
<?php 
header("HTTP/1.1 301 Moved Permanently"); 
header("Location: http://www.jb51.net/"); 
exit(); 
?> 
asp.net 301转向代码 
复制代码 代码如下:
<%@ Page Language="C#" %> 
<script runat="server"
protected void Page_Load(object sender, EventArgs e) 

HttpContext.Current.Response.StatusCode = 301; 
HttpContext.Current.Response.Status = "301 Moved Permanently"
HttpContext.Current.Response.AddHeader("Location""http://www.jb51.net"); 

</script
301代表永久性转移(Permanently Moved),301重定向是网页更改地址后对搜索引擎友好的最好方法,只 
要不是暂时搬移的情况,都建议使用301来做转址。 
JSP下的301重定向 
复制代码 代码如下:
<%@ page language="java" pageEncoding="GBK"%> 
<% 
response.setStatus(response.SC_MOVED_PERMANENTLY); 
response.addHeader("Location","http://www.7hinet.com"); 
%> 
可以通过filter控制需要重向的路径或页面