域名實現301跳轉的方法:
通過程序語言在對應的配置文件添加代碼,例如:
1.ASP的301跳轉代碼:
<%@ Language="VBScript" %><%
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.itdcw.com"
%>
2.PHP的301跳轉代碼:
$the_host = $_SERVER['HTTP_HOST']; //獲取主域名$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; //獲取后綴
if($the_host != 'nanjingseo.org')
{
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://nanjingseo.org'.$request_uri);
}
3.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.itdcw.com");
}
</script>
4.CGI Perl的301跳轉代碼:
$q = new CGI;print $q->redirect("http://www.itdcw.com");
5.JSP的301跳轉代碼:
<%response.setStatus(301);
response.setHeader( "Location", "http://www.itdcw.com" );
response.setHeader( "Connection", "close" );
%>